我试图通过使用字典映射模式函数的返回值来在状态行上显示vim的当前模式:
let g:modeMap={
\ 'n' : 'Normal',
\ 'i' : 'Insert',
\ 'R' : 'Replace',
...
\ 'v' : 'Visual',
\ 'V' : 'Visual Line',
\ '\<C-V>' : 'Visual Block'
\}
set laststatus=2
set statusline=%{g:modeMap[mode()]}
它适用于几乎所有模式,但是在切换到可视块模式时会抛出以下错误消息:
E716: Key not present in Dictionary: ^V
我也尝试过字符串<\C-V>
found here https://gabri.me/blog/diy-vim-statusline, CTRL-V
found here http://vimdoc.sourceforge.net/htmldoc/eval.html#mode%28%29 and ^V
这是在错误消息中写出的,但它们都不正确。
已测试版本:
- Vim 7.4、Ubuntu 16.04
- Vim 8.1、Debian 9
'\<C-V>'
-- 是 VimL 中的文字字符串。
您必须使用双引号才能使替换起作用:"\<C-V>"
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)