On 08/31/11 07:23, Lars Iselid wrote:
If you have a search statement something like this:

/[0-9]

And want to write :w the matching content to a file. How to do? I've
seen examples similar to this:

/[0-9] . w>>  my.txt

Depends on whether you want to write just the match, or the entire line. If you want the entire line containing the match(es), it's pretty easy:

  g/[0-9]/w>> my.txt

If you just want to write those digits to the file, it's more complex. Something like:

 g/[0-9]/t.|s/[^0-9]\+//g|w! >> my.txt | d

which copies each matching line to the line below, deletes all the non-digits, writes/appends the temp-line to the file, and then deletes the temp-line.

-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

Reply via email to