First of all, I'm new to vim like you.
But basically the answer is in the :redir command. it has many options to
output the command messages to registers, files etc.
Now, all you have to do is to run a :g/stringToFind command to get a message
w/ all the lines who match your search.

You can create your own command like the following:
command! -nargs=* Find set nu| silent exe 'redir @a|%g/\<<args>\>/' |redir
end|tabnew|normal "aP|dd"

Now, all you have to do is to type "Find cat" and it will open a new tab
with all the lines numbers and the lines containing the word 'cat'.

Now, I know it's looks awkward, but it works perfectly (doesn't it?) and you
couldn't possibly expect more from a beginner.

cheers 
alex
cheers.


fuzzylogic25 wrote:
> 
> 
> Hi,
> 
> 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?
> 

-- 
View this message in context: 
http://old.nabble.com/search-for-occurrences-in-document-and-copy-it-tp28838398p28839025.html
Sent from the Vim - General mailing list archive at Nabble.com.

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