How do I copy command output in vim?
-------------------------------------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Melt
--
Chapters
00:00 Question
00:38 Accepted answer (Score 60)
01:02 Answer 2 (Score 18)
01:22 Answer 3 (Score 5)
01:55 Answer 4 (Score 5)
02:12 Thank you
--
Full question
https://superuser.com/questions/167352/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #vim #gvim
#avk47
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Melt
--
Chapters
00:00 Question
00:38 Accepted answer (Score 60)
01:02 Answer 2 (Score 18)
01:22 Answer 3 (Score 5)
01:55 Answer 4 (Score 5)
02:12 Thank you
--
Full question
https://superuser.com/questions/167352/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #vim #gvim
#avk47
ACCEPTED ANSWER
Score 62
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
ANSWER 2
Score 18
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.
ANSWER 3
Score 6
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.
ANSWER 4
Score 6
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)