Hi, jayeola wrote: > Looking for a string when editing a file..... > > :%g/^function > > How does one save these results somewhere? Code is slowly growing and > I an tempted to write these results down ;-) !!
One possible way: :g/^function/.w! >> my-functions.lst This will append every line that starts with "function" to the file my-function.lst. I removed the range (%), because for :g % is the default. This might get slow, because on every matching line the file is opened, the line is written, and the file is closed. Also you have to make sure the file does not exist if you want to create a clean list. Another way: :redir @a :g/^function/ :redir END :new :put a :w my-functions.lst This redirects the list of your functions to register @a, creates a new buffer, and pastes the content of register @a into the new buffer. This has the advantage of letting you edit the result before saving it and doing just one write at the end. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin) -- 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
