[英]How to copy text in Emacs Evil-Mode without overwriting the clipboard?
This post described how to do it in Vim, where one prefixes their copy command with "
+ <register name>
(ie k
). How can I do this in Emacs Evil-Mode? 这篇文章描述了如何在Vim中做到这一点,其中一个前缀为"
+ <register name>
(即k
)的复制命令。如何在Emacs Evil-Mode中执行此操作?
For example, I tried the following: 例如,我尝试了以下方法:
yy
- copy first line to clipboard yy
- 将第一行复制到剪贴板 jjj
- move to some new line jjj
- 转移到新的一行 "kyy
- copy second line to register k
"kyy
- 复制第二行来注册k
p
- paste first line p
- 粘贴第一行 "kp
- paste second line "kp
- 粘贴第二行 However, at p
, Emacs pastes my second line, as if the register was ignored and copied directly to the clipboard. 但是,在p
,Emacs粘贴我的第二行,就好像该寄存器被忽略并直接复制到剪贴板一样。 Any suggestions on how to use Vim-like registers? 关于如何使用类似Vim的寄存器的任何建议? If not, any suggestions on how to copy and paste multiple regions in Evil-Mode? 如果没有,有关如何在邪恶模式下复制和粘贴多个区域的任何建议?
I think setting this value will do it: 我认为设置这个值会做到这一点:
(setq x-select-enable-clipboard nil)
Using evil (in spacemacs), "+y
still copies to clipboard, so I think that should work. 使用邪恶(在spacemacs中), "+y
仍然复制到剪贴板,所以我认为这应该工作。
If not, this blog post describes a more verbose method: Write handlers for all ways you can delete to avoid touching the clipboard and rebind keys to use these handlers. 如果没有, 这篇博客文章描述了一个更详细的方法:编写处理程序,以便您可以删除所有方法以避免触摸剪贴板并重新绑定密钥以使用这些处理程序。
This is 100% the solution, if you're spacemacs and probably otherwise: 这是100%的解决方案,如果你是spacemacs而且可能是:
(fset 'evil-visual-update-x-selection 'ignore)
Credit to: https://emacs.stackexchange.com/a/15054/8377 相信: https : //emacs.stackexchange.com/a/15054/8377
It behaves similarly in vim. 它在vim中表现相似。 Numerical registers get overwritten no matter what register you intended to use. 无论您打算使用哪个寄存器,数字寄存器都会被覆盖。 Running your examples in both Emacs (w/ evil of course) and Vim I get the k
register filled up correctly and under register 0
, the most recent yank that happens to be the same as in k
. 在Emacs(当然是邪恶的)和Vim中运行你的例子我正确地填充k
寄存器并且在寄存器0
,最近的yank恰好与k
相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.