Two Useful Commands for Capturing Output of Vim

Capture Output of Shell Commands(“:!{cmd}”)

read Execute {cmd} and insert its standard output below the cursor or the specified line.

:read !ls -al

The output will be appended to the current buffer below the cursor by default. Read :h read for details.

Capture Output of Vim Ex commands (“:”)

redir Redirect messages to register {a-z}. It also works with system clipboard.

" start redir to the plus buffer
:redir @+
" the command you want to run, e.g.
:set guifont?
" end the redir with
:redir END

read :h redir for details.

View Comments

comments powered by Disqus