I’ve been trying to extend the functionality of these three commands (y,c,d), so I’d have the content both in the system clipboard (“+ register) and in the normal registers.
This is what I’ve come up with so far:
nnoremap Y y$v$"+y$
nnoremap yy 0y$0v$"+y$
vnoremap y ygv"+y
" ------
nnoremap C y$v$"+c
nnoremap cc 0y$0v$"+c
vnoremap c ygv"+c
" ------
nnoremap D y$v$"+d$
nnoremap dd 0y$0v$"+d$
vnoremap d ygv"+d
" ------
And I have a few issues with this mapping:
- For some odd reason, I have to resource my .vimrc before I can actually use these new bindings.
Trying to use only nmap, vmap or even map just didn’t seem to work at all. - When I try to yank (for example) multiple lines (e.g. 2yy), it yanks the text to the “regular” register (“0) as expected, but yanks only the first line into the system clipboard.
- I could’nt find a way to create this behaviour to y,c and d in normal-mode.
Can anyone help solve these issues?
I thought of creating a function, perhaps, so I could call it multiple times, but my vim script-fu is novice at best.
If you can do
"+y, all these mappings are useless. Just addset clipboard+=unnamedplusto your~/.vimrc.