Friday, February 26, 2010

RE: vi, search string and comment line howto?

omonte7 wrote:
> I should be able to string all the above commands together
> separated by a pipe:
> vi -c "/my_string | I# | :wq" file

This is the Vim mailing list (not vi)!

There is an example using g// at:
http://vim.wikia.com/wiki/Power_of_g

However I would just do a substitute:

vim -c "%s/.*my_string.*/# &/" myfile.txt

The .* before and after means it finds the whole line, and the &
in the replacement represents that whole line.

John

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

No comments: