On Thu, June 10, 2010 5:33 am, fuzzylogic25 wrote:
> I am new to Vim. I am trying to open a very large document and copy the
> occurrence of a particular word in every line. So for example lets say the
> word "cat" appears 500 times in a 50,000 line document. I would like those
> 500 lines saved to a file somehow, or at least copied so I can somehow
> save
> it to a file.
>
> Is there a way of doing this in vim? or should i use c programming to do
> it?

Try this:
:let @a=""
This clears register a. Then
:g/cats/:y A/
this appends all lines, that match cats into register a and
then you have all matching lines in your register a.

You can then copy it for example into your systems clipboard using:
:let @+...@a

or you can simply put it in a new buffer:
:put a


regards,
Christian

-- 
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