y
ank by itself merely copies the line into a clipboard - you will need to p
aste it onto the next line or onto the P
receding one to use the copied line. To cut the line as well, use d
elete.
Frage
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?
Lösung 2
Andere Tipps
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
It does not do anything visible - just like Ctrl-C (Edit/Copy) in other editors. Try the command p
(paste) after it - that's the equivalent of Ctrl-V - to put what was yanked into the document.
The yank command pulls text into a clipboard. For example yy
simply yanks the current line into the common clipboard. You can "paste" the contents of the clipboard with p
. You can also yank into named buffers using something like "ayw
to yank the text from the current position to the end of the word into a buffer named a
. The correspond put is "ap
.
If your using Ubuntu or Mint the only solution that seemed to work for me was to uninstall vim and install the package "vim-gnome" instead. Then adding the line:
set clipboard=unnamedplus
to my .vimrc worked as expected.