如何将非 ASCII 字符粘贴到 vim 中?
我的终端模拟器配置为 Unicode 字符编码,并且我的 .vimrc 包含该行,
set encoding=utf-8
但是当我尝试将单词“café”粘贴到 vim 中时,它显示为“café”。
我可以通过键入 Ctrl-vu 后跟 4 字符代码点 (00e9) 在 vim 中创建“é”,但我希望能够将其粘贴进去。
My terminal emulator is configured for Unicode character encoding and my .vimrc contains the line
set encoding=utf-8
but when I try pasting the word "café" into vim, it comes out as "café".
I can make an "é" in vim by typing Ctrl-vu followed by the 4-character code point (00e9) but I'd like the ability to paste it in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
解决方案是取消选中 Terminal.app 设置的“高级”选项卡中的“转义非 ASCII 输入”复选框。
The solution was to uncheck the "Escape non-ASCII input" checkbox in the Advanced tab of the Terminal.app settings.
您可以使用 vim 的二合字母功能将其添加到文件中,而不是从剪贴板复制字符并将其粘贴到文本编辑器中。
因此,使用默认设置,使用您的示例,您可以进入插入模式,然后按 Control-k,然后键入 e'。结果将是 é。
查看定义的二合字母列表
您可以通过运行:digraphs
查看一般帮助
,并通过运行:help digraph
,其中还解释了如何自定义映射。
如果您确实决定粘贴字符,则 Shift-Insert 一直对我有用。
Instead of copying the character from the clipboard and pasting it into the text editor, you can add it to the file using vim's digraph feature.
So, with default settings, using your example, you could enter insert mode, then hit Control-k, and type e'. The result will be é.
You can see the list of defined digraphs by running
:digraphs
and general help by running
:help digraph
which also explains how to customize your mappings.
If you are truly set on pasting the characters in, Shift-Insert has always worked for me.
如何在 vi 中输入非 ASCII 代码
您必须知道您的编码是什么才能输入正确的代码,我假设您将 VI 保留为默认值。
在 VI 中,进入插入模式,在插入模式下,按
Ctrl-v 172
这应该插入此处定义的逻辑非(横向和倒置的 L)字符:
http://www.htmlhelp.com/reference/charset/iso160-191.html
How to type a non ASCII code into vi
You'll have to know what your encoding is to enter the proper codes, I assume you left VI at the default.
In VI, go into insert mode, while in insert mode, press
Ctrl-v 172
That should insert the Logical Not (sideways and inverted L) character defined here:
http://www.htmlhelp.com/reference/charset/iso160-191.html
xclip -o|xclip -i
解决方法(为剪贴板添加-sel Clip
)。xclip -o|xclip -i
workaround (add-sel clip
for clipboard).