On 9/6/06, Yakov Lerner <[EMAIL PROTECTED]> wrote:
On 9/6/06, Druce, Richard <[EMAIL PROTECTED]> wrote:
> I'm trying to select all the text matching a (multi-line) pattern so I
> can put it into a separate document. I thought the global command would
> work but it only copies the first matching line, does anyone know a
> command to do this?

:g/multi-line-pattern/normal v//e"Ay
There was error in the command above. Working command is:

  let @a='' " clear the register
 :silent! g/multi-line-pattern/exe "normal v//e\n\"Ay"

This accumulates multi-lines containing multiline patterns
into register A. Explanation:
v//e   turn current pattern into visual selection
"Ay   append visual selection to register A

For best results, make pattern match up to and including
the trailing \n of the last line of the mathing line (append .*\n if needed).
Otherwise, last substring of the previous match will merge with
first substring of next match in "A.


Reply via email to