Is there any way to copy all lines from open file to clipboard in VI editor. I tried yG but it's not using clipboard to store those lines.
So is it possible?
Is there any way to copy all lines from open file to clipboard in VI editor. I tried yG but it's not using clipboard to store those lines.
So is it possible?
This is what I do to yank the whole file:
If your fingers default to
CTRL-A CTRL-C
, then try the mappings from$VIMRUNTIME/mswin.vim
.I have them mapped to
<Leader><C-a>
and<Leader><C-c>
.The clipboard is buffer +. To copy to clipboard, do "+y and [movement].
So, gg"+yG will copy the whole file.
Similarly, to paste from clipboard, "+p
on Mac
copy selected part: visually select text(type
v
orV
in normal mode) and type:w !pbcopy
copy the whole file
:%w !pbcopy
past from the clipboard
:r !pbpaste
Another easy way to copy the entire file if you're having problems using VI, is just by typing "cat filename". It will echo the file to screen and then you can just scroll up and down and copy/paste.
Well, all of these approaches are interesting, however as lazy programmer I use yank all line by using combination of number +
y
for example you have source code file with total of 78 lines, you can do as below:
gg
to get cursor at first liney
--> it yanks 78 lines below your cursor and current line