I would like to have a good guide to the common Control key combinations in use in bash (and similar) shells and the combinations used by common programs in use in those shells.

My particular motivation is to be able to run GNU screen on one computer, ssh to a second computer and use screen and irssi on that computer. So I need to use something other than Ctrl-A to control one of the screen sessions. So I need to know what are Control key combinations are safe to use.

But I imagine this list would be useful for others who want to bind custom actions to Control key combinations.

I reckon we'd be best to group the Control key combinations by application (eg. bash itself, screen, vim, emacs), to make it easy to spot the applications you use or can ignore. So please one application per answer - hope that works.

  • 2
    To address your particular motivation, I would discourage running screen-within-screen if you can avoid it: why do you want to use screen to maintain an ssh connection to another screen session? The point of screen is to allow ssh to close without losing your active program. I would suggest to just ssh to the second computer in a separate terminal. If you do have to do it (I have done so in the past), I find there is actually less cognitive load if I simply leave the default key bindings alone. You're forced to be conscious of when you're in the inner screen anyway. Mar 20, 2010 at 18:52

6 Answers 6


Bash itself uses the GNU readline library, as do many other interactive command-line programs. Readline has the following default key bindings which mimic emacs behaviour:

Moving about on the line:

  • Ctrl + A Go to the beginning of the line you are currently typing on
  • Ctrl + E Go to the end of the line you are currently typing on

Editing text on the line:

  • Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
  • Ctrl + H Same as backspace
  • Ctrl + W Delete the word before the cursor
  • Ctrl + K Clear the line after the cursor
  • Ctrl + T Swap the last two characters before the cursor
  • Esc + T Swap the last two words before the cursor


  • Ctrl + L Clears the Screen, similar to the clear command
  • Ctrl + R Let’s you search through previously used commands
  • Ctrl + C Kill whatever you are running
  • Ctrl + D Exit the current shell
  • Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
  • 4
    These are for the emacs (set -o emacs) key bindings (bind -p). They would be different for vi (set -o vi) key bindings. Mar 16, 2010 at 0:39
  • @Dennis yes, but the keys are actually determined by the readline library, which lots of programs use. Bash has 'set -o vi' but other programs don't. So even if bash is used with vi keys, these would still conflict with other programs. I updated this answer and added one for emacs. Mar 20, 2010 at 18:44
  • @Zac: But you can set editing-mode vi in an inputrc file. Mar 20, 2010 at 19:11

Vim uses:

  • Ctrl-B back (up) one screen
  • Ctrl-D down half screen
  • Ctrl-E scroll text up (cursor doesn't move unless it has to)
  • Ctrl-F foreward (down) one screen
  • Ctrl-G show status
  • Ctrl-H backspace
  • Ctrl-J line down
  • Ctrl-L refresh screen
  • Ctrl-N move down one line (or scroll forward through autocompletions)
  • Ctrl-P move up one line (or scroll backward through autocompletions)
  • Ctrl-R redo (after undo)
  • Ctrl-T go to the file/code you were editing before the last tag jump
  • Ctrl-U up half screen
  • Ctrl-V enter visual block mode
  • Ctrl-W used for managing split windows
  • Ctrl-Y scroll text down (cursor doesn't move unless it has to)

Emacs uses everything. From http://www.cs.rutgers.edu/LCSR-Computing/some-docs/emacs-chart.html :

  • C-SP set-mark-command
  • C-a beginning-of-line
  • C-b backward-char
  • C-c exit-recursive-edit
  • C-d delete-char
  • C-e end-of-line
  • C-f forward-char
  • C-g (not explicitly mentioned in the link above, but used as a 'cancel' when entering commands)
  • C-h help-command
  • C-i (TAB) indent-for-tab-command
  • C-j (LFD) newline-and-indent
  • C-k kill-line
  • C-l recenter
  • C-m (RET) newline
  • C-n next-line
  • C-o open-line
  • C-p previous-line
  • C-q quoted-insert
  • C-r isearch-backward
  • C-s isearch-forward
  • C-t transpose-chars
  • C-u universal-argument
  • C-v scroll-up
  • C-w kill-region
  • C-x Control-X-prefix
  • C-y yank
  • C-z suspend-emacs
  • C-] abort-recursive-edit
  • C-_ undo

It seems that Ctrl+Q would be an ideal escape key for GNU screen, is there a reason that nobody seems to suggest it?

The only downside I can think of is that on Mac OS X Command+Q is the keyboard shortcut for quitting an application which would be slightly dangerous if confused with Ctrl+Q.

Otherwise, from the current answers and my own research it seems that nothing conflicts with Ctrl+Q.

  • 1
    Your terminals stop and start features are usually controlled by C-s and C-q, but its not very common (correct me if I am wrong) that people use this at all since its way easier to pipe into less, more or other processing tools. I'd safely say that you can rebind C-q without much hazzle. In my shells I always change the stty settings for start and stop to avoid pausing output unintentionally, I do this with: stty start '' stop '' in my bash startup scripts. Jan 7, 2012 at 2:20
  • FYI: When using PuTTY, If you accidentally hit Ctrl+s (XOFF) you need Ctrl+q to get your session responding again. May 24, 2012 at 14:49

Lots of application uses the GNU readline library, so those keybindings are good to know about. You can study them in the readline(2) manual page, easily viewed here:


GNU screen by default uses Ctrl-A as its command key.

  • 2
    To use the Bash emacs-mode Ctrl-A (beginning-of-line) while running screen, press Ctrl-A followed by A (or press Home). Mar 16, 2010 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.