How do I copy command output in vim?

Are you looking for this,

:redir @* | set guifont | redir END

:redir command redirects the output of a command to a register (@*). The register @* refers to the clipboard.

For more info on this,

:help :redir

Try ':r !pwd' to get the current working directory directly in to the GVIM opened file.
You can then copy it to clipboard like you would any other text file contents opened there.


If you're running vim in an xterm, holding the shift key while selecting the text will copy the text to the X equivalent of the clipboard.


For this particular example you could do (note the "!" which makes it go through the shell):

:!pwd | xclip

or

:!pwd | xclip -selection secondary

(depending on which X-selection you want).

You might have to install xclip first

sudo apt-get install xclip

(or equivalent)