Would it be possible to configure iTerm 2 to go backwards and forwards one word through the curent text in the command line using a keyboard shortcut?

  • 6
    This doesn't really answer the question but it's relevant: you can option+click anywhere in a command line to move the cursor there. – David Winiecki Apr 19 at 22:52
up vote 30 down vote accepted

Ctrl-[ b jumps back a word. You can also use Esc instead or Ctrl-[, and f to go forward.

That is Ctrl+[ release and then b orf. Or Esc and b or f.

More information can be found at this other discussion on AskDifferent.

I like the following setup.

  1. Preferences > Profiles > Keys
  2. Click the plus.

move forward one word

send escape

move back one word

send escape

delete to beginning of word (credit)

send hex code
0x1B 0x08

delete to end of word

send escape
  • 2
    On MacOS 10.12, I need to use hex code 0x17 to get delete to beginning of word – midopa Jan 20 '17 at 4:16
  • works like a charm with macOS 10.12 and zsh – Sébastien Feb 7 '17 at 14:23
  • 1
    best answer ever you have a beer from me :) – infinity Jun 9 '17 at 13:46
  • 1
    Consider upvoting jherran's answer. I think I just improved on their answer a little and probably should have suggested an edit instead of creating my own answer. I kind of feel like I stole it. – David Winiecki Jun 17 '17 at 2:54
  • Referenced this: to do Esc-b, I had to send 0x1b 0x42, and for Esc-f, I had to send 0x1b 0x46 :D – Meredith Oct 13 '17 at 17:59

Killing a fly with a cannon:

  • Go to Preferences... > Profiles > Keys
  • Press Load Preset...
  • Select Natural Text Editing

Then, you can move a word backwards using Option ⌥ + and a word forwards using Option ⌥ + . Also you can delete a word backwards using Option ⌥ + , delete the whole line using Command ⌘ + , and more.

If the preset doesn't appear, reinstall iTerm2. If you installed it using Homebrew+Cask:

brew cask reinstall iterm2
  • 14
    This should be the accepted answer! – guyarad Sep 7 '17 at 2:31
  • 2
    This doesn't work for me. Parameters: iTerm2 3.1.2, macOS 10.12.6, german Keyboard. And I'm not alone... – t0r0X Oct 29 '17 at 18:16
  • This is great and will add most of your needs. It however does not add a 'go to start/end of line via CMD + left arrow/right arrow`. For that action, see: stackoverflow.com/questions/6205157/… – MikeyN0 Oct 3 at 23:07
  • 3
    My life has changed after I saw this answer. I divorced my wife, now I am in a Lambo with a supermodel. – Dragos Rizescu Oct 16 at 20:51

To Get Forward (Alt-f), Backward (Alt-b) and Delete (Alt-d) Word

  1. Open iTerm.
  2. Go to iTerm > Preferences... > Profiles > Keys
  3. Under Profile Shortcut Keys, click the + sign.
  4. Type your key shortcut (option-b, option-f, option-d, option-left, etc.)
  5. For Action, choose Send Escape Sequence.
  6. Write b, d or f in the input field.

This works at least for bash. For zsh there are other ways to navigate.

  • 1
    I tried to add an option+right shortcut and got a warning message about a conflict, because I didn't realize that you can configure keys both in Preferences > Keys > Global Shortcut Keys and also Preferences > Profiles > Keys > Profile Shortcut Keys. Configuring it in the default profile worked. – David Winiecki Sep 8 '15 at 3:48
  • It works for zsh as well! – Andrii Abramov Jun 30 '17 at 16:33
  • I think your answer (to the same solution) was the easiest to understand +1 – nzaleski Oct 29 at 12:39

Similar to other answers, but for Zsh it took me a while to find this:

If you are using Zsh, like Oh My Zsh, in iTerm then go to: Preferences > Profiles > Keys sub-menu

Click + sign

Add your shortcut combo, choose "Send Escape Sequence"

inputs for left and right below.




  • 1
    You saved my life mate – thibaut noah May 31 '17 at 8:40
  • This is the only solution that worked for me – Bryji Oct 2 '17 at 10:44
  • Finally, a simple solution that works :D Thanks for sharing it with us! – Periback Aug 1 at 7:08

You can set your terminal in vi mode with set -o vi to be able to use the usual vi motion commands (add the line in .bash_profile to store the setting permanently.)

So, as if in vi, you can hit Esc, then b to move one word backward (w for forward), go to the beginning of the line with 0, or search a character backward with F + the char.

Hit i to go back to Normal mode and insert.

Those familiar with vi can do much more.

With iTerm2 3.1.4, I was able to setup the following without adding individual key mappings.

  1. Go to Preferences > Profiles > Keys
  2. Left/Right ⌥ Key: Select Esc+

With a new Terminal session you are now able to use:

Option ⌥ + f to Get Forward

Option ⌥ + b to Get Forward

Option ⌥ + Delete ⌫ to Delete Word

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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