7

I would like to view the output of echo in vim, and save to a file after having a look at it. I have tried echo $PATH | vim, but I get the following error:

Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...

Vim: Finished.

What can I do?

rrauenza
  • 307
Human
  • 623

2 Answers2

8

You're missing the - filename argument that instructs Vim to fill the buffer from stdin; cp. :help --

echo $PATH | vim -

Alternatively, you can use your shell's process substitution to create a temporary file descriptor and have Vim edit that "virtual" file.

vim <(echo $PATH)
Ingo Karkat
  • 23,523
6

How can I redirect output from stout into vim?

Your question has been answered on AskUbuntu.

The simplest solution is to add - to your command:

echo $PATH | vim -

You can use process substitution (this also works with applications that can't read from STDIN):

vim <(ls -la)

Or use vim's function to read from STDIN:

ls -la | vim -

Source How do I redirect command output to vim in bash?, answer by Chaos

DavidPostill
  • 162,382