Skip to content

Instantly share code, notes, and snippets.

@kxzk
Created January 8, 2018 04:15
Show Gist options
  • Save kxzk/b97197faaca99ea4a4fe1d3a798c1c0e to your computer and use it in GitHub Desktop.
Save kxzk/b97197faaca99ea4a4fe1d3a798c1c0e to your computer and use it in GitHub Desktop.
" Dictionary: take mode() input -> longer notation of current mode
" mode() is defined by Vim
let g:currentmode={ 'n' : 'Normal ', 'no' : 'N·Operator Pending ', 'v' : 'Visual ', 'V' : 'V·Line ', '^V' : 'V·Block ', 's' : 'Select ', 'S': 'S·Line ', '^S' : 'S·Block ', 'i' : 'Insert ', 'R' : 'Replace ', 'Rv' : 'V·Replace ', 'c' : 'Command ', 'cv' : 'Vim Ex ', 'ce' : 'Ex ', 'r' : 'Prompt ', 'rm' : 'More ', 'r?' : 'Confirm ', '!' : 'Shell ', 't' : 'Terminal '}
" Function: return current mode
" abort -> function will abort soon as error detected
function! ModeCurrent() abort
let l:modecurrent = mode()
" use get() -> fails safely, since ^V doesn't seem to register
" 3rd arg is used when return of mode() == 0, which is case with ^V
" thus, ^V fails -> returns 0 -> replaced with 'V Block'
let l:modelist = toupper(get(g:currentmode, l:modecurrent, 'V·Block '))
let l:current_status_mode = l:modelist
return l:current_status_mode
endfunction
set statusline=
set statusline+=\ %{ModeCurrent()}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment