2010/1/11 rakeshg <rakeshbab...@gmail.com>: > > I tried to find a regular expression to transform a line > > This is what is required: > > From: > something "ab,cd,ef,gh,..." > To: > something > something.ab,something.cd,something.ef,something.gh,something.ij,....
I don't think you can do this with a regular expression in Vim. How about something like: function! ExpandStuff(linecontents) let searchpattern = '^\(\k\+\)\s\+"\(.\{-}\)"' let prefix = substitute(a:linecontents, searchpattern, '\1', '') let suffixes = split(substitute(a:linecontents, searchpattern, '\2', ''), ',') let new_line = "" for item in suffixes let new_line .= prefix . "." . item . "," endfor return new_line endfunction Having defined this, you should be able to do: :%s/^something ".*"/\=ExpandStuff(submatch(0))/ Hope that helps, although it may contain the odd bug as I typed it directly into the email rather than testing it (sorry!). If you don't want a trailing comment (it wasn't clear from your example), you'll need to modify it accordingly (either strip it off the end or only add it if it's not the last one). Al -- http://sites.google.com/site/abudden
-- You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php