【发布时间】:2019-05-23 22:22:16
【问题描述】:
我正在尝试通过使用字典映射 mode 函数的返回值,在状态行上显示 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, CTRL-V found here 和 ^V 写在错误消息中,但它们都不正确。
测试版本:
- Vim 7.4,Ubuntu 16.04
- Vim 8.1、Debian 9
【问题讨论】:
标签: vim