I've this in my vimrc

let g:currentmode={
            \ 'n'      : 'NORMAL  ',
            \ 'v'      : 'VISUAL  ',
            \ 'V'      : 'V·Line  ',
            \ '^V' : 'V·Block ',
            \ 'i'      : 'INSERT  ',
            \ 'R'      : 'REPLACE ',
            \ 'c'      : 'COMMAND ',
            \ 't'      : 'TERM    '

set statusline=
            \\ %{&filetype!=#''?&filetype:'none'}
            \\ \ %{&fileformat==#'unix'?'U':&fileformat==#'dos'?'D':'N'}
            \\ \ %{expand('%:~:.')!=#''?expand('%:~:.'):'[No\ Name]'}
            \%=\ %3p%%\ \ %l:\ %3c

The character that you see as the key in the currentmode dictionary for the value V.Block is something I inserted by pressing <C-v><C-v, but here it shows up as a box, so I changed it into ^V for the sake of visibility here in the forum. I don't want a keyword like that in my vimrc, is there any way I can change it into something like <C-v>? I've tried \<C-v>, and <C-v>, doesn't work either of these.

  • "...here it shows up as ." Shows up as what? And then, "...any way I can change it into something?" Something? A set of car keys? A top hat? What exactly do you want to change it into? – B Layer Feb 8 '19 at 14:09
  • " here it shows up as ." was not my fault. When I wrote the question vi.stackexchange showed me a box, then after posting the question it disappeared. – klaus Feb 8 '19 at 14:14

The problem are the single-quotes you are using. Single quotes enclose "literal-strings", in these strings, the backslash is not a escape character, but just a backslash.

You could use double-quotes like "\<C-v>". Just try the following two commands:

:echo '\<C-v>'
:echo "\<C-v>"

You might want to read :help string and :help literal-string.

| improve this answer | |
  • I knew about literal-strings and strings, but didn't occur to me in this case! – klaus Feb 8 '19 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.