sponsor Vim development Vim logo Vim Book Ad

vimcaps : Toggle off capslock when back to normal mode.

 script karma  Rating 138/39, Downloaded by 2348  Comments, bugs, improvements  Vim wiki

created by
LiTuX S.
 
script type
utility
 
description
vimcaps
Never be bothered by caps lock.

As is known, capslock is almost useless in vim's normal mode. If it happens that the capslock is locked, you know what the fuck is going to happen:

+ You want to move up, but came out a man;
+ You wanna move down, but line joins;
+ You try to undo those joins, but it undo itself;
+ ...

So, lots of vimmers disabled the capslock or map it to another key. Yes, that is a beautiful solution. I don't like capslock too. But someday, I notice that the capslock is still useful, ---if you have to use an on screen keyboard (e.g., with a touch screen) Then I decide to do a simple thing instead of remap the keyboard: Toggle off the capslock when back to normal mode, ---that is what this plugin do.

vimcaps now support Windows and Linux (actually xWindow, we need Xlib), TTYs are still not supported. BSD hasn't been tested, suggestions are welcomed. Since I don't have a mac, there won't be any mac support until someone send a pull request. :)

Linux support may have some bug (Although according to my test, only with such a strange way can vimcaps work. I'm using ubuntu 13.10 and a logitech small keyboard and onboard BTW). What we need to know is that, xWindow have a shift lock modifier. I don't know if such a lock exists on a physical keyboard or not, but Xlib functions can't change onboard's shift lock. So this shift lock is still a problem.

Usage:
After install, this plugin will automatically handle the capslock for you: vimcaps register autocmd for toggle off the capslock when InsertLeave, BufferWinEnter and FocusGained. Note that FocusGained may don't work if you are under a terminal.

Starting from 0.0.3, vimcaps provide a function vimcaps#statusline() in order to display the keyboard locks status on the statusline. You'll need to add it to your statusline settings to enable it.

set stl=...%{vimcaps#statusline(N)}...

More information can be obtained from the source, or check out:
https://github.com/suxpert/vimcaps
 
install details
If you download the package from vim.org, unzip the package to your vimfiles folder.

For Linux user, you need to compile the library manually, or let vimcaps compile it automatically. make, gcc, Xlib must be installed first.

For vundle and vim-addons-manager user, please visit:
https://github.com/suxpert/vimcaps
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vimcaps-0.1.1.zip 0.1.1 2014-02-22 7.0 LiTuX S. Add option to disable the autocmd (use the statusline function only, for example);
Restructured, move most code into autoload/vimcaps.vim
vimcaps-0.1.0.zip 0.1.0 2014-02-15 7.0 LiTuX S. vimcaps now support xWindow, hence version became 0.1.0. :)
vimcaps-0.0.3.zip 0.0.3 2014-01-25 7.0 LiTuX S. Add "vimcaps#statusline()" function for displaying the keyboard lock status in statusline.
vimcaps-0.0.2.zip 0.0.2 2014-01-20 7.0 LiTuX S. Optimize functions, add some high level function for numlock and scrollock, add vimcaps#dance() function for fun. Let's dance! :)
vimcaps-0.0.1.zip 0.0.1 2014-01-16 7.0 LiTuX S. Initial upload
ip used for rating: 3.92.96.247

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github