Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I work with Vim I almost never look at my keyboard (like it should be!) and this is great, but sometimes, unknowingly I hit the CapsLock key and causes me to yell at my screen.

Because, you know, j is not the same as J in normal mode (and so on).

So instead or mapping CapsLock to say Ctrl I want to display an error message that will warn me in normal mode if this is the case.

Is there a way for Vim to tell if you have CapsLock enabled?

Note: I prefer a VimScript/VimL solution for portability and because I want Vim to notify me and not depend on the actual system.

share|improve this question

migrated from stackoverflow.com Jul 27 '11 at 10:58

This question came from our site for professional and enthusiast programmers.

2  
Get rid of caps lock, you don't need it. If you ever need to type in all caps for more than 60 sec drop a burden in your shift key. –  sidyll Jul 26 '11 at 12:52
1  
I'm specifically saying that I do not want to do that, so no point in suggesting I should get rid of it. –  alfredodeza Jul 26 '11 at 13:01
1  
I find the CapsLock key so easy to hit that I remapped it to Escape. Works for me. :) –  dash-tom-bang Jul 26 '11 at 17:42
    
Along with converting my caps lock to Escape, it's also a Control. Yes, it's both an escape and a control at the same time! In linux, you do can do so via xmodmap -e "add Control = Escape". Hope you enjoy. :-) –  evaryont Jul 27 '11 at 5:41
    
CapSee does the job on OS X. Not the answer you were looking for, but it happens to be the right answer most Apple users. –  Earl Feb 13 at 7:34

1 Answer 1

You can use a script like this:

; INDICATE WHEN THE CAPS LOCK IS ON WITH A SCREEN MESSAGE
Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
Gui, Font, caf001e s30 bold ,Verdana ;changes font color, size and font
Gui, Color, af001d;changes background color
Gui +LastFound  ; Make the GUI window the last found window for use by the line below.
WinSet, TransColor,af001d
Gui, Add, Text, ,CAPS LOCK ON
; TOGGLE THE GUI ON AND OFF
~capslock::
   if(0==GetKeyState("capslock","T")){
      Gui,  hide
   }else{
      if(guilocation>0){
         guilocation=0
         Gui, Show,x600 y800 NoActivate
      }else{
         guilocation=1
         Gui, Show,x600 y400 NoActivate
      }
   }
return 

Taken from Here. Now Vim will display CAPS LOCK ON whenever your caps lock is on

Update: And that's a script for AHK (Automatic hotkey scripting language). According to this conversation it is impossible to create a behaviour your're descripting using only vim.

share|improve this answer
1  
what language is that? I would prefer to have VimScript/VimL to make Vim take care of that (updating my question) –  alfredodeza Jul 26 '11 at 12:49
1  
That's for AHK (Automation hotkey scripting) so no use for you. Tried to look from google and couldn't find anything vim specific for your problem :/ –  OsQu Jul 26 '11 at 12:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.