Skip to content

Instantly share code, notes, and snippets.

@snoblenet
Last active May 5, 2017 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snoblenet/87ac44249709083032931aa94d46d334 to your computer and use it in GitHub Desktop.
Save snoblenet/87ac44249709083032931aa94d46d334 to your computer and use it in GitHub Desktop.
Caps Lock and Insert mode warning for Vim
" 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment