Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In terminal emulation applications, pressing CTRL + Left / Right arrows jumps from one word to the previous or next one. Is it possible to have the same functionality in a Linux console, whether it is in text or in framebuffer modes?

In my configuration, the CTRL + arrow keys are transformed into escaped character sequences and not interpreted.

share|improve this question
up vote 7 down vote accepted

This is possible if and only if the terminal sends different escape sequences for Ctrl+Left vs Left. This is not the case by default on the Linux console (at least on my machine). You can make it so by modifying the keymap. The exact file to modify may depend on your distribution; on Debian lenny, the file to modify is /etc/console/boottime.kmap.gz. You need lines like

control keycode 105 = F100
string F100 = "\033O5D"
control keycode 106 = F101
string F101 = "\033O5C"

You might as well choose the same escape sequences as your X terminal emulator. To find out what the control sequence is, type Ctrl+V Ctrl+Left in a shell; this inserts (on my machine) ^[O5D where ^[ is an escape character. In the keymap file, \033 represents an escape character.

Configuring the application in the terminal to decode the escape sequence is a separate problem, .

share|improve this answer
you are only explaining how you got the "\033O5D" code, but completely omitting where you got the keycode 105 and F100 codes from. Besides, I get ^[[1;5B and ^[[1;5A for ctrl+Down and Ctrl+Up. How should I handle the 1; part? – Martin Vegter Apr 20 at 10:08
@MartinVegter Check the existing file for keycodes, or use the showkey program. The 1; part isn't different from the rest: "\033[1;5B" and so on. – Gilles Apr 20 at 10:29
OK the keycode 105 can be found using showkey. But where did you get the F100 ? – Martin Vegter Apr 20 at 10:44
@MartinVegter Pick one that isn't already in use. A different one per keychord (I just fixed a typo in my answer). – Gilles Apr 20 at 12:01

Emacs-style shortcuts Alt+F, Alt+B work by default with all readline-powered command line programs, like shells.

share|improve this answer

You can set vim as your command line editor and then hit ESC and jump around vim style (forward, back, end, $, 0, etc)

share|improve this answer

I had this issue on Debian with an empty ~/.inputrc file. Fixed the problem by removing this file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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