Monday, February 21, 2011

Vim Usage: how to press your ``Esc''

In vim, how would you press the Esc key to switch from insert mode to command mode? For sure, it is a key that you need to move your hand out of alphabet keys. Some people would slap the key..haha..it sounds a little bit violence. For me, I use my little finger, huh, some people think I have a very big hand or a very long little finger.

If you have read Vim Tips, you probably know what's going on. In fact, I am pressing cap lock instead of Esc. In Linux, it is convenient to set your key. You can use xmodmap to modify X windows layout. Since I seldom to use Cap lock, and in order to speed up using vim, I swap Esc and Cap lock. To do that, you can create a .Xmodmap with following content under your home directory
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock

Then execute
$ xmodmap ~/.Xmodmap

Then you will realise that your caps lock become Esc key already. For sure, if you like this mapping, you need to start the script on Gnome start up to take the effect.

No comments:

Post a Comment