简体   繁体   English

如何将非ASCII字符粘贴到vim中?

[英]How do I paste non-ASCII characters into vim?

My terminal emulator is configured for Unicode character encoding and my .vimrc contains the line 我的终端仿真器配置为Unicode字符编码,我的.vimrc包含该行

set encoding=utf-8

but when I try pasting the word "café" into vim, it comes out as "café". 但是当我尝试将“café”这个词粘贴到vim中时,它就像“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. 我可以通过键入Ctrl-vu后跟4个字符的代码点(00e9)在vim中创建一个“é”,但我希望能够粘贴它。

解决方案是取消选中Terminal.app设置的“高级”选项卡中的“Escape non-ASCII input”复选框。

How to type a non ASCII code into vi 如何在vi中键入非ASCII代码

You'll have to know what your encoding is to enter the proper codes, I assume you left VI at the default. 您必须知道输入正确代码的编码是什么,我假设您将VI保留为默认值。

In VI, go into insert mode, while in insert mode, press 在VI中,进入插入模式,在插入模式下,按

Ctrl-v 172 Ctrl-v 172

That should insert the Logical Not (sideways and inverted L) character defined here: 那应该插入这里定义的逻辑非(侧向和反向L)字符:

http://www.htmlhelp.com/reference/charset/iso160-191.html http://www.htmlhelp.com/reference/charset/iso160-191.html

  1. From where are you trying to paste it? 你想从哪里粘贴它? If it is opera, then since opera-10.5* paste is broken in both directions. 如果它是opera,那么因为opera-10.5 * paste在两个方向都被打破了。 Before pasting anything you need to use xclip -o|xclip -i workaround (add -sel clip for clipboard). 在粘贴任何内容之前,您需要使用xclip -o|xclip -i workaround(为剪贴板添加-sel clip )。
  2. What command do you use? 你用什么命令?

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. 您可以使用vim的有向图功能将其添加到文件中,而不是从剪贴板复制字符并将其粘贴到文本编辑器中。

So, with default settings, using your example, you could enter insert mode, then hit Control-k, and type e'. 因此,使用默认设置,使用您的示例,您可以进入插入模式,然后按Control-k,然后键入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. 如果你真的设置粘贴字符,Shift-Insert一直对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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