FANDOM


It's handy to get a visual reminder when you enter Insert mode, and when Caps Lock is still enabled when leaving insert mode. Do this by adding the following to your `vimrc`:

" ensure you have xset in your shell
" change 'solarized' to the name of your colorscheme
" presumes that your colorscheme, like solarized, provides both dark and light modes

function! CapsWarn()
  let CapsState = system('xset -q | grep -oE "Caps Lock:   on"')
  if CapsState =~ "on"
    highlight Normal ctermbg=Red
    redraw
    sleep 100m
    colorscheme Solarized
    redraw
  endif
endfunction

autocmd InsertEnter * set background=dark | colorscheme solarized
autocmd InsertLeave * set background=light | colorscheme solarized | call CapsWarn()

Community content is available under CC-BY-SA unless otherwise noted.