As a Linux user, I am very used to jump from word to word in vim/nano using ALT+left or right.

This doesn't seem to work properly using iTerm, I am using zsh, I tried adding;

bindkey -e
bindkey '^[[1;9C' forward-word
bindkey '^[[1;9D' backward-word

It does work, but inside zsh only, then I commented those lines and added in iTerm a keyboard shortcut;

enter image description here

It does work, but only for the ALTleft

How can I make it work for the right arrow too?

5 Answers 5


In iTerm's properties go to Profiles -> Keys and setup there

  • For ⌥→ Send Escape Sequence [1;5C
  • For ⌥← Send Escape Sequence [1;5D

enter image description here

  • That doesn't work for me. The escape sequences are sent, but vim only moves one space back and forth. Running the default vim 7.3 that comes with OS X 10.8. Ideally, I'd like to change it on vim's side, not tweaking the defaults of the Terminal emulator (since that'll result in better portability).
    – slhck
    Sep 6, 2013 at 7:01
  • That's weird, it works both in vim (from homebrew, not a default one) and zsh with the default configuration from oh-my-zsh (in ~/.oh-my-zsh/lib/key-bindings.sh).
    – eiennohito
    Sep 6, 2013 at 7:04
  • Doesn't work here either, I can use alt + arrow in inside zsh, in Vim it only works with shift + arrow :(
    – seds
    Sep 7, 2013 at 17:34
  • I checked it one more time on available remote systems (ubuntu 13.04, stable debian, and scientific linux) and it works everywhere. What is the output when you press Control+V, ⌥→? For me it is ^[[1;5C
    – eiennohito
    Sep 8, 2013 at 9:03
  • Works for me: iTerm/Vi + zsh Jan 31, 2014 at 2:20

Start by viewing the key code your terminal is sending to vim:

$ sed -n l

In the above example, i ran the sed command and pressed Alt + Left.

The ^[[1;9D is the escaped sequence being sent to vim, so we can user that for our mapping.

Add to vimrc:

map <Esc>[1;9D :tabn<CR>

alternative solution for macOS

if sed -nl is not working as expected, try CTRL + V instead

You can determine the current mapping using the "control-V trick": First press control-V, then the keystroke you like to examine. This will print the characters that are sent to the terminal. http://www.macfreek.nl/memory/Backspace_and_Delete_key_reversed

For example typing control-V + delete prints ^?. I have only verified this on macOS 11.

  • what's the key code for delete?
    – Niing
    Jan 2, 2021 at 8:04
  • try ctrl + v and then press the delete key instead of the sed cmd which prints nothing. i get this (running osx): ^? Jan 2, 2021 at 21:49

I read another post describing that for option-left and option right, you need to bind them to the actions ^[b and ^[f, respectively. That is, you bind them to "Send escape sequence" and bind key b and f.



None of those answers worked for me. I ended up loading a linux VM and checked what I'd get with <Alt-ARROW>.

The 4 escape sequences which worked for me are those:

  • <Alt+Up>: [1;3A
  • <Alt+Down>: [1;3B
  • <Alt+Right>: [1;3C
  • <Alt+Left>: [1;3D

Be careful to edit the Profile keys and not the main ones which will be overridden by the Profile ones (where Alt + Arrows are set by default to an Hex Sequence which didn't work with vim).


Just an other possible solution, vim offers word motions on its own, see:

:help word-motions
  • 3
    You should include the essential information instead of just putting a reference here. Jan 24, 2014 at 12:39

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.