Super User is a question and answer site for computer enthusiasts and power users. 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 the default Cygwin installation, using CTRL-LEFTARROW or CTRL-RIGHTARROW simply prints 5C or 5D instead of skipping a word at a time as expected.

Home/End keys work properly, so remapping should be possible.

share|improve this question

migrated from Oct 15 '12 at 21:16

This question came from our site for professional and enthusiast programmers.

Found a solution, posting it here for posterity.

Add the following lines to ~/.inputrc (C:\cygwin\home\<username>\.inputrc):

"\e[1;5C": forward-word   # ctrl + right
"\e[1;5D": backward-word  # ctrl + left 

When done you can press C-x C-r to re-read the .inputrc file for the current session.

Things to note if you want other similar customisations: Use 5A and 5B for up and down arrows, and 2x for shifted versions.

The "official" key mappings are described in the Bash Reference Manual, but for a quick way to find a key mapping, in bash:

  1. type Ctrl+V
  2. type the key sequence you are interested in (e.g., Alt+). This would print ^[[1;3C
  3. remove the leading ^[ and replace it with \e to make \e[1;3C
  4. place this value in your .inputrc file.
share|improve this answer
Awesome! Thanks! – Zoltán May 30 '14 at 11:40
This was bugging me for a while, thanks a lot! – Edenshaw Mar 3 at 14:01
Some keyboard codes are not showing at all like <kbd>Shift</kbd> + <kbd>Enter</kbd>. How do I find these keyboard codes via Mintty/Windows/Cygwin? – CMCDragonkai Apr 6 at 12:06

You can reload file .inputrc via:

bind -f ~/.inputrc


share|improve this answer

In case you want something that'll work without custom environment settings, for instance when working on a shared account on a server or just to limit the amount of custom configuration being used, Bash has built-ins for this that work in Cygwin.

Namely Alt+f to move forward and Alt+b to move backward.

share|improve this answer
Thanks, though I am aware of those keys and do use them. I just also use the arrow keys when it's convenient and don't want them spewing escape codes instead of doing the sane thing and moving the cursor. – Tom Mar 20 '13 at 22:23

When using rxvt with cygwin I found the solution at this link worked for me: control_arrow_keys_in_rxvt.

Add the following lines to ~/.inputrc :

"\eOd": backward-word
"\eOc": forward-word
share|improve this answer
That's when an additional layer is changing the transmitted keys (but it doesn't answer the question asked). – Nikana Reklawyks Nov 3 '12 at 20:46

You must log in to answer this question.

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