tags:

views:

366

answers:

3

How can you put a list of files to Vim's -o -mode?

I have a list of files as Grep's output. I run unsuccessfully

1

grep -il sid * | vim -o

2

grep -il sid * | xargs vim -o

3

grep -il sid * | xargs vim

4

vim -o `grep -il sid *`

5

vim -o | grep -il sid *
+1  A: 

Run:

grep -il sid * | vim -

This tell vim to read the file from stdin, so the output of grep will be in vim. Now, put cursor on file and press gF - this will open the file on the line grep indicated.

You can also use ^WF to open file in a new split.

dimba
+3  A: 

Second one works for me. Third too, although you get only one file visible at the start. 4 is the same as 2 in most cases. First and last should not work by design.

liori
I cannot understand what was a problem in my Zsh. The commands work similarly for me now.
Masi
Funny, I use zsh too. So something must have went very bad for you for a moment :-)
liori
A: 

The second one should work unless some of those filenames contain whitespace. You should do

grep -il sid * | xargs -d "\n" vim -o

if this is a possibility. -d "\n" tells xargs to use a newline as the delimiter when reading in the arguments; normally it is any whitespace (newline, tab, or space character)

intuited