Reputation: 11730
The copy-paste functions in vim seem a bit inconsistent to me. The commands yy
, dd
and cc
yank/delete the whole line. The commands D
and C
delete from the cursor to the end of line, but Y
yanks the whole line instead. I want Y
to work the same as D
and C
. So I put the following line in my .vimrc
:
nmap Y y$
It doesn't seem to work though. My first idea was that it is because of some plugin interfering. I tried to put the command to both the beginning and the end of my .vimrc
, but nothing helped. However, if I type the command manually (not from .vimrc
), it works. Why is this? How do I make this work?
Upvotes: 3
Views: 2685
Reputation: 13931
Pasting a new answer as code is not formatted in the comment of the answer above.
If the conflict is YankRing you can use:
function! YRRunAfterMaps()
nnoremap Y :<C-U>YRYankCount 'y$'<CR>
endfunction
nnoremap Y y$
source: :help yankring-custom-maps
Upvotes: 2
Reputation: 356
Your vimrc is loaded before plugins are loaded, so this doesn't rule out that a plugin is overriding it. Placing .vim files in .vim/after/
will be loaded after plugins so you could test that theory that way if you want to avoid the route of removing your plugins one-by-one.
As mentioned by Kent, you should really consider using nnoremap
over nmap
.
Upvotes: 5