I'm using xterm version 293. While navigating in a command, I normally use the short-cut keys as Ctrl+LeftArrow or Ctrl+RightArrow to move back and forth.

But while doing so, rather expected behaviour, Ctrl+LeftArrow prints 5D and Ctrl+RightArrow prints 5C

How to make the xterm work as per expectation ?


e.g. In xterm, if I type:

shw$ This is a test

If the cursor is after is and I press Ctrl+LeftArrow, then I'm expecting that cursor should move On i of is (and again pressing Ctrl+LeftArrow, cursor must go at T of This). But instead, I get the result as

shw$ This is5D a test

Same for Ctrl+RightArrow

1 Answer 1


To support Ctrl-arrows in xterm, set the modifyKeyboard resource to at least 2. For instance:

xterm -xrm "*modifyKeyboard: 2"

If this doesn't have the expected behavior, perhaps your application (its key bindings) is not correctly configured. Or you can also try to modify the modifyCursorKeys resource, e.g.

xterm -xrm "*modifyKeyboard: 2" -xrm "*modifyCursorKeys: 0"

You need to configure your applications to recognize the escape sequences. For instance, with *modifyCursorKeys: 2 (which is the default) and zsh:

bindkey '\e[1;5C' forward-word
bindkey '\e[1;5D' backward-word

and for applications based on libreadline, such as bash:

"\e[1;5C": forward-word
"\e[1;5D": backward-word

in your ~/.inputrc file.

  • First command have no effect. Second command also have no effect except, 5D and 5C is not getting printed
    – SHW
    Commented Aug 11, 2014 at 8:43
  • @SHW You need to give more information. For instance, where do you get the expected behavior?
    – vinc17
    Commented Aug 11, 2014 at 8:49
  • See the edited question
    – SHW
    Commented Aug 11, 2014 at 8:57
  • @SHW Well, xterm works as expected. The problem should come from your applications, which need to be configured. See my edited answer for zsh and readline based applications. If this still doesn't work for you, you should give more details.
    – vinc17
    Commented Aug 11, 2014 at 9:29
  • 1
    Thanks. libreadline solution is working
    – SHW
    Commented Aug 11, 2014 at 9:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .