[CentOS] Feed a list of filenames to vim

Wed May 18 13:54:53 UTC 2011
Bowie Bailey <Bowie_Bailey at BUC.com>

On 5/18/2011 12:50 AM, Jussi Hirvi wrote:
> On 17.5.2011 19.36, Bowie Bailey wrote:
>> Try this:
>> vim `cat list`
> Thanks, this really works! I tried it with all my combinations:
> OS X workstation by itself
> OS X workstation -> ssh -> CentOS 4
> OS X workstation -> ssh -> CentOS 5
> BTW, with the xargs command, all of these combinations give some 
> problems. The cause may have something to do with my terminal settings. 
> Anyway, now I can use `cat list`.

The problem is that you were screwing up vim's stdin.  Using the method
I gave you, you are just taking advantage of shell features to provide a
list of filenames to vim on the command line.

If your list looks like this:


Then when you do "vim `cat list`", the shell expands it to this:

$ vim file1 file2 file3

You can also do this:

$ vim `ls -1 *.txt`

or this:

$ vim `find /some/dir -name '*.txt'`

It works with any command that outputs a list of filenames.