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.


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.

| 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. – Andrew Wood Feb 2 '12 at 16:20
  • gvim --servername NAME --remote-send ':read !cat file.txt<CR>' works. – romainl Feb 2 '12 at 17:23
  • gvim --servername NAME --remote-send ':vnew | :read !cat file.txt<CR>' works too. – romainl Feb 2 '12 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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