如何在Vim中将字符串输入字符串?

Fed*_*reg 19 vim

无法弄清楚这一点.只需要在字符串中输入1个表情符号就无法弄明白.Unicode不起作用.尝试过,但也没有用.在Vim中有一些技巧吗?谢谢!

DJM*_*hem 33

您无需为此安装插件.您需要做的就是输入表情符号的unicode值.您可以在插入模式下执行此操作<C-v>.来自:h i_ctrl-v_digit:

                        *i_CTRL-V_digit*
With CTRL-V the decimal, octal or hexadecimal value of a character can be
entered directly.  This way you can enter any character, except a line break
(<NL>, value 10).  There are five ways to enter the character value:

first char  mode         max nr of chars   max value ~
(none)      decimal        3        255
o or O      octal          3        377      (255)
x or X      hexadecimal    2        ff       (255)
u           hexadecimal    4        ffff     (65535)
U           hexadecimal    8        7fffffff (2147483647)
Run Code Online (Sandbox Code Playgroud)

例如,如果要输入具有unicode值的笑脸,则U+1F60A只需键入:

<C-v>U1F60A<esc>
Run Code Online (Sandbox Code Playgroud)

或者如果你不想打<esc>,

<C-v>U0001F60A
Run Code Online (Sandbox Code Playgroud)

您知道,根据您的字体,它很有可能无法在vim中正确呈现.如果您正在使用gvim,您可以更改:se guifont=*或在常规vim中更改您的控制台字体以使其呈现(假设您选择可以呈现此特定表情符号的字体)


bit*_*fet 14

另一种方法是使用缩写。

我在我的.vimrc 文件中添加了一些,现在我只需输入 :pushpin: for 、 :bulb: for 、 :bomb: for 等等...

" Emoji shortcuts
ab :white_check_mark: ?
ab :warning: ?
ab :bulb: 
ab :pushpin: 
ab :bomb: 
ab :pill: 
ab :construction: 
ab :pencil: 
ab :point_right: 
ab :book: 
ab :link: 
ab :wrench: 
ab :info: 
ab :telephone: 
ab :email: 
ab :computer: 
Run Code Online (Sandbox Code Playgroud)

emojicopy.com或类似网站上还有更多。我只是挑了一些我以前用过的。


gi1*_*242 5

虽然这是可能的<c-v>U1f60A<esc>,但如果您要回复电子邮件/在网络表单中输入评论,则这是不切实际的。我不会为了快速的“谢谢”评论而记住 unicode 表情符号表。

对于此类用例,几乎没有其他选择:

  1. 输入您常用的表情符号:),然后使用插件将其替换为等效的 unicode 符号。插件 emoji-ab可以为你做到这一点。

  2. 键入代码,例如:boom:. 许多 Markdown 解析器会将其转换为你的。但如果您没有使用这样的解析器, emoji-ab也会为您进行转换。

  3. 使用 gucharmap (或众多在线 Unicode 选择器之一)之类的工具将 unicode 字符复制并粘贴到 vim 中。


小智 5

在包括 Vim 在内的许多环境中访问这些表情符号的另一种方法是使用字符映射对话框窗口:

  • 在 Mac 上,按Ctrl+ Command+Space并选择字符。
  • 在 Windows 上,按Windows+R并输入字符映射。

Charmap 选择器图像