Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim "yank" does not seem to work

Tags:

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?

like image 268
Adam Rubin Avatar asked Jul 10 '13 02:07

Adam Rubin


People also ask

How do I yank in vim?

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.

How do I yank to clipboard in vim?

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.

What is +Y vim?

y stands for yank in Vim, which in other editors is usually called copy.

How do I enable clipboard in vim?

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".


1 Answers

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 
like image 179
Weston Ganger Avatar answered Dec 07 '22 19:12

Weston Ganger