我无法想出解决方法。只需要将一个表情符号输入到字符串中,但无法解决。Unicode不能正常工作。尝试过双字母组合,但还是不行。在Vim中有什么诀窍吗?谢谢!
您无需安装插件即可实现此操作。您只需要输入表情符号的 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)
例如,如果你想输入这个微笑的表情符号,它的Unicode值为U+1F60A
,那么你只需输入:<C-v>U1F60A<esc>
或者如果您不想按下<esc>
,
<C-v>U0001F60A
提醒一下,根据您使用的字体不同,它可能无法在vim中正确呈现。如果您使用gvim,可以更改:se guifont=*
,或者在常规vim中更改控制台字体以使其呈现(假设您选择了一个可以呈现此特定表情符号的字体)
另一种方法是使用缩写。
我在我的 .vimrc 文件 中添加了一些,现在我只需键入 :pushpin: 代表📌,:bulb: 代表💡,:bomb: 代表💣 等等...
" 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:
在emojicopy.com或类似的网站上有更多的表情符号。我只是挑了一些以前已经用过的。
sudo apt install fzf
pip install emoji-fzf
现在,请确保您可以运行emoji-fzf。
emoji-fzf --help
如果你遇到了“命令未找到”的错误,请查看pip安装包成功,但无法从命令行找到可执行文件
现在将emoji-fzf添加到你的.vimrc文件中
" Use emoji-fzf and fzf to fuzzy-search for emoji, and insert the result
function! InsertEmoji(emoji)
let @a = system('cut -d " " -f 1 | emoji-fzf get', a:emoji)
normal! "agP
endfunction
command! -bang Emoj
\ call fzf#run({
\ 'source': 'emoji-fzf preview',
\ 'options': '--preview ''emoji-fzf get --name {1}''',
\ 'sink': function('InsertEmoji')
\ })
" Ctrl-e in normal and insert mode will open the emoji picker.
" Unfortunately doesn't bring you back to insert mode
map <C-e> :Emoj<CR>
imap <C-e> <C-o><C-e>
重新启动您的vim,按下ctrl + e,搜索您最喜欢的表情符号,然后按enter键。