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
grep -il
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)
Sorry I'm late. Some of these options work for me but with weird side effects. Try this:
vim -o $(grep -il sid *)
To invoke vim
using xargs
, xargs
must be invoked with -o
:
grep -il sid * | xargs -o vim -o
In case filenames could contain spaces, use grep -Z
with xargs -0
grep -ilZ sid * | xargs -0 -o vim -o
Without xargs -o
, we would get a warning:
Vim: Warning: Input is not from a terminal
The -o
option exists on OSX/BSD. Also, the -o
option is found in GNU findutils built from git. This option was added after 4.6.0.
Try
vim -p `grep -il sid *`
if you want to open the files in different tabs in the same window.
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.
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.