Vim:仅在yank命令中使用+作为默认寄存器 [英] Vim: Use + as default register only for yank command

查看:54
本文介绍了Vim:仅在yank命令中使用+作为默认寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想对+指令使用+注册(系统剪贴板) (也就是说,不要在 dd 或其他命令)。

I'd like to use + register (system clipboard) only for yank command (that is, don't overwrite this register on dd or other commands).

:set clipboard+=unnamed

不起作用,因为它引入了上述的 dd 覆盖。

won't work, because it introduces dd overwriting described above.

推荐答案

您可以覆盖默认的yank命令,以便将它们默认为系统剪贴板,除非明确指定了其他寄存器:

You can overwrite the default yank commands so that they default to the system clipboard, unless another register is explicitly given:

:nnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
:nnoremap <expr> yy (v:register ==# '"' ? '"+' : '') . 'yy'
:nnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'
:xnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
:xnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'

这篇关于Vim:仅在yank命令中使用+作为默认寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆