On Wed, 6 Sep 2006 at 7:01am, Yakov Lerner wrote: > On 9/6/06, Elliot Shank <[EMAIL PROTECTED]> wrote: > > Hari Krishna Dara wrote: > > > On Wed, 6 Sep 2006 at 12:18pm, Druce, Richard 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? > > > > > > I don't see any Vim primitives to work with multi-line matches. I think > > > the searchpos() function should be extended to return the [line, col] of > > > the end of the match as well. May be I am missing something, but in the > > > absence of primitives, you can probably write a function which will > > > try to guess what the matching lines are, something like this (only > > > partly tested): > > > > None of this is necessary. The simple solution is to use the uppercase name of a register, which appends to the register, rather than the lower case version, which replaces. > > I think the point of the question was how to yank > multiple lines corresponding to multi-line pattern. > For single-line pattern, you're right, it's trivial. > > Yakov
Right, Thanks Yakov. For single-line patterns, there is also a trick you can use to write the matches directly to the file. I think it is: :g/pattern/.w! >> file -- Hari __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com