Is there any chance to write the content of the current vim buffer to stdout?
I\'d like to use vim to edit content that was passed via stdin - without the need of a
I think :w !tee
would work perfectly,
You can also use pipe.vim. It does use a temporary file, but at least you don't have to worry about it in your own script.
To the second part of your question, you use the -s
command line option with vim to remap :w
to something else (like :w !tee
).
Since you use Linux/Unix, you might also be interested in trying out moreutils. It provides a command called vipe
, which reads from stdin
, lets you edit the text in $EDITOR
, and then prints the modified text to stdout
.
So make sure you set your editor to Vim:
export EDITOR=vim
And then you can try these examples:
cat /etc/fstab | vipe
cut -d' ' -f2 /etc/mtab | vipe | less