Emacs Keybindings

Emacs Keybindings

My workstation keyboard at home doesn't have arrow keys. Someone asked why I'd use a keyboard like this - which is a pretty fair question. It's because I'm used to emacs keybindings for navigating text in the terminal.

My keyboard is a Happy Hacking Keyboard. The sort advocated by names like Richard Stallman and Bjarne Stroustrup. These keyboards use a topre switch mechanism. Rubber-dome switches that also feature a conical spring. It's very comfortable to type on, and also quite quiet.

The HHKB typically comes with a UNIX layout without arrow keys. It has a modifier fn key that can be used to make other keys send arrow keycodes - but I'd argue you don't want to use them on a UNIX-like system to begin with. Aside from arrows, the biggest change is likely the replacement of the Caps Lock key with control - a welcome change by my evaluation.

Without arrow keys, movement within the terminal (and your editor) is instead achieved using either key-combinations (as in Emacs and Readline), or modes (Vim's hjkl). Your terminal likely uses readline.

Using key-combinations to move the cursor is less intuitive. I'm not going to argue otherwise. I do recall when I first started using emacs, I held onto my arrow keys for dear life. But then I started making an effort to touch type, and the constant shifting back and forth between home-row and off-to-the-side got in the way.

The basics of movement in the terminal are as such:

Key   Action
----- ----------------------------
C-a   Move to start of line
C-e   Move to end of line
C-f   Move forward one character
M-f   Move forward one word
C-b   Move back one character
M-b   Move back one word

And history:

Key   Action
----- ----------------------------------------------
C-p   Fetch history n-1
C-n   Fetch history n+1
C-r   Fetch history backwards (interactive search)

And finally, cutting and pasting. Which are known as killing and yanking. Though some keys may not work on MacOS as they are used for other things:

Key   Action
----- ----------------------------------------
C-d   Delete character under cursor
M-d   Delete word under cursor
C-k   Delete from cursor to end of line
C-u   Delete from cursor to start of line
C-y   Insert the last item deleted at cursor