I am running Mavericks on a new Macbook Pro. When I use the Ctrl and Shift keys together with the arrow keys, I get some sort of key codes as output in the terminal. I am pretty sure that this problem is new and that it didn't happen a few days ago. But I am not 100% sure. Anyway, this is what happens:

If I press Ctrl+ (Left arrow), ;5D is output in the terminal. Similarly:

  • Ctrl+ (Right arrow) outputs ;5C
  • Shift+ (Left arrow) outputs ;2D
  • Shift+ (Right arrow) outputs ;2C

As I mentioned, I am pretty sure that before today I could use those shortcuts to move between words and select text. Has anyone seen this before? I have already looked through some of the existing questions about arrow key shortcuts, but I have found no references to this exact problem.

Also, note that I have turned off the keyboard shortcut that moves between desktops using the Ctrl + arrow keys.

  • Your arrow keys are remapped somewhere to use \],- (the ascii equivalent of hex 5C 5D 2C 2D).
    – l'L'l
    Jan 3 '14 at 21:46
  • Would you care to elaborate? I am very new to OSX. Where would I look for these remappings? Jan 7 '14 at 8:28

The same thing happens on my 10.9 and 10.8 VMs. Control-arrows and shift-arrows don't do anything by default in bash. Where were you even using shift-arrows to select text? emacs or vim?

If you want to use control-left and control-right to move between words in bash, add these lines to ~/.inputrc:

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

To use shift-arrows in Emacs, map shift-up to \e[1;2A, shift-down to \e[1;2B, shift-right to \e[1;2C, and shift-left to \e[1;2D. If pressing shift-up results in a message like <select> is undefined, try setting TERM to xterm-vt220.

  • I guess I may have been wrong about using the shift-arrows to select text. I am a developer with 13 years of experience but this is my first go at OSX. Very confused so far. Jan 7 '14 at 8:43
  • Figured out the .inputrc thing. Looked everywhere for the file until I realised I have to create it myself. :) I can now move between words again. So thanks for that, I am marking this as the answer. Just a couple more questions so I am 100% clear: 1: I have now switched to using iTerm2. Is there any way, using .inputrc or otherwise, to get Shift+Left and Shift+Right to select text in iTerm2? 2: You mentioned emacs and vim. Aren't these just text editors? How would I use them as a terminal? Jan 7 '14 at 9:43
  • I don't know any way to make shift-left and shift-right modify the selection in iTerm 2. I thought you might have used them just in Emacs.
    – Lri
    Jan 8 '14 at 13:45
  • Alright. I'll have to live without it for now. Thanks! Jan 8 '14 at 14:54
  • 1
    It doesn't work on macos Sierra, Shift + Right Arrow or Shift + Left Arrow doesn't do anything. Jan 11 '17 at 8:36

Ctrl+Left/Right are present in Terminal (macOS 10.12) by default (Preferences → Profiles → Keyboard). I tried adding Shift-Up/Down in ~/.inputrc but nothing happened.


"\e[1;2A": shift-up
"\e[1;2B": shift-down

Instead I added Shift Up/Down programatically in Terminal Preferences. The problem is that this is stored per profile, of which macOS has a dozen by default, so you have to loop over all the profiles (one named Ocean here) to add the keys for all available profiles. I don't know if plutil or defaults have some magic to make this easy, or if you have to use an XML parser.


"Window Settings" = {
  Ocean = {
    keyMapBoundKeys = {
      "$F700" = "\033[1;2A";
      "$F701" = "\033[1;2B";

In Iterm2 you can do it (I have 3.3.12) and followed this instruction: https://superuser.com/questions/1051668/select-full-word-in-iterm2-using-alt-shift-arrow/1216606#1216606?newreg=bd3be1406dcb4aaa856f425d3e5f2c24

I've set these mappings in Prferences- > Keys but then also had to remove the mappings for shift+arrows from Preferences ->Profile -> Default (they were sending escape sequences there).

This may break down the workflow for programs that run inside the terminal like emacs (I did not check) but works great for me for selecting in the command line and in the mcedit (builtin editor of midnight commander) as well.

The selection logic is a bit different, it is not following the cursor but for simple cases it works great.


An alternative:

In Terminal preferences go to Advanced and unselect 'Paste newlines as carriage returns'.

Then use Sublime to write out complicated com

You must log in to answer this question.

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