Archive for February, 2012
How to bind the Windows key to the Escape key in Vim for Ubuntu
Posted by Michael Okarimia in Handy Tips on February 11, 2012
Here’s a nice tip I’ve just discovered when using Vim on the Ubuntu OS on a computer equipped with a windows keyboard. Most PC keyboards have Windows specific keys on their bottom row, such as the Windows start menu key and the context menu key.
With the default key bindings in Vim, it can be a pain to reach up to hit the escape key to exit insert mode.
I discovered that you can bind the Windows key at the bottom row of the keyboard to act as the escape key.
To do this, you need to edit your ~.bashrc file and add the following line:
xmodmap -e “keysym Super_L = Escape”
The changes will come into effect once you restart your terminal. Then you’re good to go.
There are many alternative keybindings, and I was wary of swapping the escape and caps lock key bindings because of unintended side effects.
I had previously mapped typing jj
to exit from insert mode by adding the following to my .vimrc file
:imap jj
After about a year of using jj
I wanted to use something quicker and the windows key binding above was my solution.
Happy Vimming!