How to use a pipe to edit a file with vi

you might try this:

% vi `cat file.txt`

or, to avoid the useles use of cat:

% vi `< file.txt`

you are telling vi(m) just a bunch of arbitrary things. if you want vi(m) to do something like 'hey, open that file' you have to feed it the same commands you would use in vi(m), eg. something like :e foo.txt. but thats just more complicated than doing what i proposed.


At least for vim (not sure about vi), you can do

cat file.txt | vim -

The '-' tells vim to read from stdin.