Thanks to all of you who posted, and I apologize for posting in the wrong forum and for reposting (something was up with my post being accepted to nabble). The following both worked great, I needed a vim only solution as I'm running on various distributed operating systems and sed (with out the -i option) was to much work.
vim -c "/my_string/s/^/#/" -c "wq" file vim -c "%s/.*my_string.*/# &/" file Produced desired output: # cat file line 1 and stuff # line 2 contains my_string line 3 and stuf Thanks! On Mar 2, 11:23 pm, "John Beckett" <[email protected]> wrote: > omonte7 wrote: > > Subject: vi, search string and comment line howto? > > You must be having trouble with your mail system because > you have posted the same message three times. > > The replies to your message are > here:http://groups.google.com/group/vim_use/browse_thread/thread/3ff28355f... > > I have set your account to "moderated" so that any further > repeats can be removed before appearing on the list. > > While doing that I notice that you are set to > No Email - read this group on the web > so I will send a CC. > > 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
