Thanks for all your replies, you have helped me alot and i really appreacite it
I tried :g/cat/.w! >> out.txt The problem with this is, for each time it finds one occurrence of cat, it then appends it to out.txt. So for each occurrence, the hard disk head moves. This causes alot of mechanical movements. Is it possible to save it to a buffer first, then write ALL of that to the file? Also, can you tell me how you got to become experienced with vim? There are just soo many features/commands i dontk now where/how to start learning Tim Chase-9 wrote: > > On 06/09/2010 10:33 PM, 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? > > In addition to the other good answers you've already gotten: > > :g/cat/.w! >> out.txt > > should dump every match to a file (if the file out.txt > pre-exists, it appends) > > :help :w_a > > -tim > > > > -- > 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 > > -- View this message in context: http://old.nabble.com/search-for-occurrences-in-document-and-copy-it-tp28838398p28857396.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
