I'm trying to display the current mode of vim on the status line by mapping the return value of mode function by using a dictionary:
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()]}
It works well for almost all modes, however it throws the following error message in case of switching to visual block mode:
E716: Key not present in Dictionary: ^V
I've also tried the string <\C-V>
found here, CTRL-V
found here and ^V
which was written out in the error message but neither of them was correct.
Tested with versions:
'\<C-V>'
-- is a literal string in VimL.
You must use double quotes to make the substitution work: "\<C-V>"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With