0

Right now I'm creating a plugin of sorts for Vim, it's meant to simply have all kinds of utility functions to put in your statusline, here's the link: https://github.com/Greduan/vim-usefulstatusline

So here's my question, my next addition is meant to be a little output that tells you whether you have CAPS lock on or off, it would output [CAPSLOCK] if it's turned on, and nothing if it's turned off.

Any help is greatly appreciated. :)

greduan
  • 4,770
  • 6
  • 45
  • 73

1 Answers1

3

There is no way you can query this independent of the system, at least with not any default vim plugin or python module (don’t know about other interpreters). You can use just the same hack as suggested here for linux

echo and(system('xset q | grep LED')[65], 1)

I never saw people actually wanting caps lock in vim anyway.

Community
  • 1
  • 1
ZyX
  • 52,536
  • 7
  • 114
  • 135
  • I can see tpope made a plugin for this: https://github.com/tpope/vim-capslock And it uses the same method my .vimrc uses I think: https://github.com/Greduan/dotfiles/blob/aac797dcb31e2bff65e18ddcaad5def548111664/vim/vimrc.vim#L500-L518 – greduan Jan 27 '13 at 20:12
  • @Eduan This method has nothing to do with actual CapsLock, it just maps all a-z characters to their uppercase variants and A-Z to their lowercase variants. You will have to examine `maparg` output to check, something like `maparg('a', 'i') is# 'A' && maparg('A', 'i') is# 'a'` – ZyX Jan 28 '13 at 03:06
  • Ah, I see, that makes sense. I guess I'll have to research some stuff in order to achieve this. :) BTW how's the file size stuff? Is it better? – greduan Jan 28 '13 at 03:09