Using many control keys during the day, such as Ctrl-f to page down in Vim and Ctrl-c to kill a process in terminal, and assigning some of my own to tmux, I’ve began wondering whether all the letters of the alphabet were accounted for. The answer is: yes, they are; plus even some extra characters.
Most key bindings differ depending on the context, except ones in the “term” column that always keep the same function. The layers that I’m most interested in are:
- the shell (bash/zsh with Emacs key bindings), where I edit commands and browse history;
- process control while running a process attached to the terminal;
- Vim, which I use exclusively in the terminal.
I have compiled a comprehensive overview of all control key bindings in different contexts and highlighted the features that matter to me the most:
|start of line
|move back a char
|half page down
|end of line
|move forward a char
|kill text to end of line
|move cursor down
|move cursor up
|zsh: clear line
|backward inc. search
|forward inc. search*
|undo tag jump
|half page up
|insert next char literally
|visual block mode
|prefix, e.g. C-x,C-e
|exit insert mode
|jump to tag
In the shell, these are indispensable:
- C-r - Backward incremental search through history
- C-s - Forward incremental search
C-s doesn’t work by default.
Here’s how to enable it:
# Allow <C-s> to pass through to shell and programs
stty -ixon -ixoff
For process control:
- C-z - Suspend a process. Useful for switching away from a man page or Vim while keeping the option to return to it intact.
- fg (shell) - Return a process to foreground
- jobs (shell) - List suspended processes
- C-f/b - Page down/up
- C-a/x - Increment/decrement the number after cursor. Can’t do CSS without it!
- C-] - Jump to tag under cursor
- C-o - Backtrack after having jumped
To learn more about navigating tags and jumps in Vim, see Vim: Revisited.