On Friday, July 6, 2012 4:08:30 PM UTC-5, Hoss wrote:
> > 123,456g#pattern# <- operate on all lines between 123 and 456 (inclusive) 
> > which include a match for "pattern"
> > exec "norm! ..." <- do a normal-mode command on each line, as follows:
> >   /pattern\<CR> <- search for the pattern
> >   \"Ay <- yank from the cursor position and append into "a" register
> >   //e\<CR> <- tells where to yank to, in this case to the end of the match
> 
> Ideally, the yanked text would consist of each match within the range, 
> concatenated together with a newline between each. So, if each line only has 
> 1 match, this would coincide with an exact copy of the original lines, minus 
> any non-matched text, if that makes sense.
> 
> I did try your second example but it doesn't seem to work out of the gate, 
> and I'm not having any luck tweaking it.
> 
> :%g#top="[^"]#exec "norm! /top="[^"]\<CR>\"Ay//e\<CR>"
> E15: Invalid expression: ^"]\<CR>\"Ay//e\<CR>"
> E15: Invalid expression: "norm! /top="[^"]\<CR>\"Ay//e\<CR>"

Looks like John sent you a ready-made solution, but the problem you're getting 
is that you didn't escape the quotes within the string. You need to replace 
"[^"] with \"[^\"] since the whole pattern is enclosed in "...".

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to