wasd
wasd

Reputation: 1572

How to get the current VIM mode as a string

I've build my own statusline in VIM with, to show the current mode indicator I use:

set statusline+=%#NormalColor#%{(mode()=='n')?'\ \ NORMAL\ ':''}
set statusline+=%#InsertColor#%{(mode()==?'i')?'\ \ INSERT\ ':''}
set statusline+=%#ReplaceColor#%{(mode()==?'R')?'\ \ RPLACE\ ':''}
set statusline+=%#VisualColor#%{(mode()==#'v')?'\ \ VISUAL\ ':''}
set statusline+=%#VisualColor#%{(mode()==#'V')?'\ \ V-LINE\ ':''}
set statusline+=%#VisualColor#%{(mode()=='\<C-V>')?'\ \ V-BLOCK\ ':''}

It works for all the modes except for the V-BLOCK. Is there a way to match the '\< C-V>' with such approach?

Upvotes: 0

Views: 93

Answers (1)

Kent
Kent

Reputation: 195039

This line should help you. The ^V has ascii value 22:

.....%{(mode()==nr2char(22))?'\ \ V-BLOCK\ ':''}

Upvotes: 1

Related Questions