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:
|term||shell prompt||process||Vim normal|
|C-A||start of line||increment number|
|C-B||move back a char||page up|
|C-D||delete char||send EOF||half page down|
|C-E||end of line||scroll up|
|C-F||move forward a char||page down|
|C-G||abort line||file/position info|
|C-K||kill text to end of line|
|C-N||next history||move cursor down|
|C-P||previous history||move cursor up|
|C-Q||zsh: clear line|
|C-R||backward inc. search||redo|
|C-S||forward inc. search*|
|C-T||transpose chars||SIGINFO||undo tag jump|
|C-U||clear line||half page up|
|C-V||insert next char literally||visual block mode|
|C-W||delete word||window prefix|
|C-X||prefix, e.g. C-x,C-e||decrement number|
|C-Y||yank||(delayed suspend)||scroll down|
|C-[||<Esc>||exit insert mode|
|C-]||jump to tag|
In the shell, these are indispensable:
- C-r - Backward incremental search through history
- C-s - Forward incremental search
# 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.