Keyboard Key Mapping for Emacs: Evil Mode and Rearranging Alt, Ctrl and Win Keys
Posted on In Linux, Programming, Software, TutorialCtrl keys are important and possibly most frequently used in Emacs. However, it is painful on today’s common PC keyboards since Ctrl keys are usually in the corner of the keyboard main area. Why the key mappings in Emacs are designed like this? After it was designed, Emacs was commonly on the Lisp Machine keyboards with Ctrl keys closer to the space bar as show below (src).
After the key mappings are used by the community, it is hard to change these most basic and common ones (see discussion here).
In this post, I will discuss several solutions to make using Emacs non-painfully with the help of Emacs modes, key remappings in the OS or new keyboards.
Table of Contents
Evil mode
As also a Vim user, I like the Vim key mappings which keep my hands in the keyboard’s main area without moving much (one important tip is to use Ctrl-[ for Esc). The Evil mode of Emacs emulates a Vim-like environment for cursor moving, editing and etc. With the Evil mode, one has the power of Emacs with the hand-friendly key mappings. This is my most preferred way in Emacs although some consider it evil.
For how to set up and use the Evil mode, check the page on EmacsWiki at http://www.emacswiki.org/emacs/Evil .
Changing the key positions
Although the PC keyboards have the Alt keys around the Space bar, it is possible to change the mapping of keys on the keyboard. Below are several possible solutions on Linux. Several ones are for Gnome 3. You may need to use your desktop environment’s configuration options.
- Swap alt and ctrl
- Win as Alt and Ctrl/Alt as Ctrl
- Win as Ctrl
- Caps Lock as Control
- Space bar as Ctrl or Space
Use a ergonomic keyboard
An ergonomic keyboard can make the life easier and can also be used together with above methods. There are many choices in the market at prices from 30 to several hundreds dollars. Here are ones on Amazon: Ergonomic keyboards on Amazon.