On Tue, 15 Mar 2011, Anthony Campbell wrote:

I have a directory with over 400 files, some of which contain a particular string I want to modify manually. Is there any way to tell vim to edit just the files which contain the specified string?

Within Vim, you can use the :vim[grep] command to get a list of all the matches in a quickfix list.

:vim[grep] pattern *file-glob*     " does the grep
:cope[n]                           " c = current, ope[n] the list

Personally, I prefer using external tools, since the files are usually scattered across directories and I don't necessarily want all the files in a given list of directories. (So, at work, I have some utilities to search files I use often, etc.) To open such a list of files was the reason I started using GNU Parallel[1] (after its super-helpful author replied to something like this off-list):

$ (thing to generate a list of files) | parallel -uXj1 vim

e.g. open all files containing the string '$username'
$ find-grep '$username' -l | parallel -uXj1 vim

--
Best,
Ben

[1] http://www.gnu.org/software/parallel/

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