I've got some code to print the current mode in the status line.
let g:currentmode={
\ 'n' : 'Normal',
\ 'no' : 'Normal·Operator Pending',
\ 'v' : 'Visual',
\ 'V' : 'V·Line',
\ '^V' : 'V·Block',
\ 's' : 'Select',
\ 'S' : 'S·Line',
...
Used like this set statusline+=\ %{toupper(g:currentmode[mode()])}
.
It works great for all modes except Visual Block where I get this error E716: Key not present in Dictionary: ^V
.
I've tried
- printing the mode() directly and copied that into the dictionary
- insert the Unicode character
^
(U+005E
) as described here - writing on my Swedish keyboard:
<SHIFT-¨><SPACE>
."
key is placed to the bottom left of backspace, and requires you to push it twice to produce output, or once and then space. Just to be totally safe I've tested both clicking twice, and clicking once, and thenSPACE
.
None of these methods work. I've tried finding out more about the more()
function (or what is it?), but without luck. I'm not sure where that functionality is coming from, but it's being used in several blog posts, without specifying where it's documented, for example here.
I guess there's something with my Swedish keyboard setup. I've also had problems with mappings.
Ctrl-V
, that is pressCtrl-L
, followed byCtrl-V
in insert mode – Christian Brabandt May 8 '20 at 15:26"\<C-V>": 'V-Block'
– Matt May 8 '20 at 15:41