Mahdi
Mahdi

Reputation: 2279

Vim: How to open a file whose name is determined by running a shell command

Suppose that I have a command, say find ABCD | grep text1 which outputs full-path of a file to be opened. I know I can send this output to vim using xargs and open the file, but this is possible only in command line.

How can I do this from inside vim editor?

Upvotes: 0

Views: 149

Answers (1)

mauro
mauro

Reputation: 5940

Assuming COMMAND returns exactly the path of your file, then something like this should be ok from the command line:

$ vi $(COMMAND)

and this should be ok from within vim:

:e `COMMAND`

Upvotes: 4

Related Questions