I'm fairly new to Vim. Tonight, I learned about the "yank" command, but when I try to use it in MacVim, it doesn't do anything. Neither Y
nor y{motion}
do anything. I tried with a default .vimrc
to rule out any weird config issues.
Google-fu is failing me. This feels like a noobie issue. Am I missing something obvious?
To yank one line, position the cursor anywhere on the line and type yy . Now move the cursor to the line above where you want the yanked line to be put (copied), and type p . A copy of the yanked line will appear in a new line below the cursor.
Below steps explains how to yank.In vim command mode press v , this will switch you to VISUAL mode. Move the cursor around to select the text or lines you need to copy. Press y , this will copy the selected text to clipboard.
y stands for yank in Vim, which in other editors is usually called copy.
You need to make sure clipboard is activated (which is probably not the case). if you get "-clipboard" then you would have to install vim again with the "clipboard" functionality. You can do it it by installing "vim-gtk3" or "gvim".
If you have the setting set clipboard=unnamedplus
in your .vimrc
then this will not be working.
For OSX you have to use set clipboard=unnamed
For Linux you will probably need to use set clipboard=unnamedplus
Heres the snippet from my personal .vimrc
if system('uname -s') == "Darwin\n" set clipboard=unnamed "OSX else set clipboard=unnamedplus "Linux endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With