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.

How can I set keys to be remapped for one specific program in Linux? (More specifically Caps Lock -> Escape for gVim. I hit it accidentally too much to remap it in everything).

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Check Vim's wiki on wikia.com.

If you want to completely swap the Caps Lock and Escape keys, you have to replace the "Lock" on Caps Lock. Drop this file in your home directory:

! Swap caps lock and escape
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock

and call it ".speedswapper". Then open a terminal and type

$ xmodmap .speedswapper

The swapping lasts for the duration of the X session, so you can put it in a .xinitrc or similar startup file.

There are some other interesting alternative ESC mappings as well.

share|improve this answer
    
No good. I want it changed for vim only, while this changes it for everything. –  Macha Jun 25 '10 at 11:18
    
AFAIK, it's not possible to do it inside vim because X catches the key stroke long before vi or vim can see it, that's why the official wiki doesn't have a vimrc approach. You should use an application outside vim that catches caps key on OS level (read stackoverflow.com/questions/2176532/… for more information). You can try to use a bash script to turn on/off caps lock key when needed. dancingpenguinsoflight.com/2009/01/maps-caps-lock-key-to-escape –  GmonC Jun 26 '10 at 4:09

you can write a simple bash script which can run the above mentioned solution whenever you run vim and remove the file after you close vlc.

share|improve this answer

Autokey allows you to remap keys with window filters, and it's available in most distributions' repositories. As a bonus you can even map scripts to certain keypresses, it's pretty powerful. https://code.google.com/p/autokey/

share|improve this answer

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.