简体   繁体   中英

vim: copy into system clipboard not working

In my .vimrc I have those two lines for copy and paste into the system clipboard:

nnoremap <Leader>p "+p
nnoremap <Leader>y "+y

Weirdly the remapping of pasting works fine, but I can't copy any lines. If I press the buttons "+y it works and the highlighted text is in my system clipboard, but if I use < Leader> y it is only copied into a register inside vim, but not into the system clipboard.

Some help would be great!

If you use your mapping in Visual mode, you have to use vnoremap or noremap , instead of nnoremap (which is for Normal mode only).

See :h map-overview for details.

Your yanking mapping is incorrect. "+y lacks a motion. If you want to yank the whole line use upper Y ( "+Y ) or or yy ( "+yy ).

:help y
                        *y* *yank*
["x]y{motion}       Yank {motion} text [into register x].  When no
            characters are to be yanked (e.g., "y0" in column 1),
            this is an error when 'cpoptions' includes the 'E'
            flag.

Note that, if you type "+y , vim hangs in "operation-penging mode" ( :help Operator-pending-mode ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM