Is it possible to redirect the output of a process (in bash) into an existing instance of (g)vim?

Something like:

cat myfile1.txt | awk 'print $1' | gvim -

Then I might start a new window inside my vim with :vne and want to fill it with the output from some other process.

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

Your example works but it can't be used as is from your terminal to open a second output in a second window.

You can put the output of your command in the active buffer from within Vim itself with

:read !cat myfile1.txt | awk 'print $1'

That's the simplest solution I can think of.

You can also use GVim as a server and send it your output, see :h clientserver.

link|improve this answer
I can't figure out why process substitution won't work with the --remote option. gvim --remote somefile.txt does what you'd think, but gvim --remote <( cat somefile.txt ) opens an empty file. – ajwood Feb 2 at 16:20
gvim --servername NAME --remote-send ':read !cat file.txt<CR>' works. – romainl Feb 2 at 17:23
gvim --servername NAME --remote-send ':vnew | :read !cat file.txt<CR>' works too. – romainl Feb 2 at 17:25
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.