How to Copy to Clipboard in Vim
Copy to Clipboard in Vim
Why we need this
We copy words or lines, by useing a mouce or trackpad,
double click or triple click, selecting by our finger.
However using Vim, copying lines by mouce might contain
line numbers or line end charactors. It's annoying to
delete the extra char every paste.
Vim has a nice commands that copies lines or words.
`yy`: copies one line to `register`. `num yy`: copies the numbers of lines to `register`. `yw`: copies one word to `register`. `p`: paste from the `register`.
But this register
is different from clipboard
what we use copy and paste Control C & V
in the browser.
"*
: by MacOS
`"*yy`: copies one line to `clipboard`
In MacOS, adding "*
: to prefix enable to yank(copy) to
clipboard, which is different in Linux.
* Make sure your Vim can use clipboard.
If your Vim is not supporting Clipboard, you cannot type
"*
command.
- If not, install MacVim
"+
: by Linux
In Linux, "*
: do not use clipboard.
Clipboard read the "+
register.
Use "+
instead.
unnamed, unnamed plus
This "+
can also use in Mac.
Enable Clipboard by yy
"*
or "+
costs finger. It is far from default position.
if yy
reads clipboard, it saves our time a lot.
set clipboard=unnamed
to ~/.vimrc
. Very Very Very useful!!!!!