Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the return value for visual block mode in vimscript?

Tags:

vim

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:

  • Vim 7.4, Ubuntu 16.04
  • Vim 8.1, Debian 9
like image 445
vargab95 Avatar asked Mar 04 '23 23:03

vargab95


1 Answers

'\<C-V>' -- is a literal string in VimL.

You must use double quotes to make the substitution work: "\<C-V>".

like image 175
Matt Avatar answered Apr 05 '23 23:04

Matt