h6yfda
Last Updated: April 10, 2018
·
136.5K
· e-dard

Use ⌥ ← and ⌥→ to jump forwards / backwards words in iTerm 2, on OS X

By default in iTerm 2, it's a pain to skip between words.

Here's how you can configure iTerm 2 on OSX to allow you to use ⌥ ← and ⌥→ to do just that.

First you need to set your left ⌥ key to act as an escape character.

Picture

Second you need to either locate the current shortcut for ⌥ ← or create a new one, in the Profile Shortcut Keys, with the following settings:

  • Keyboard Shortcut: ⌥←
  • Action: Send Escape Sequence
  • Esc+: b

Picture

Third, repeat for the ⌥→ keyboard shortcut with the following settings:

  • Keyboard Shortcut: ⌥→
  • Action: Send Escape Sequence
  • Esc+: f

You're done! Now you can skip entire words on the command line by holding down the left ⌥ key and hitting ← or →

To make this work for the right option key you need to set the key modifier to act as an Escape Sequence, a la the first step.

42 Responses
Add your response

7441

thx for the trick :)

over 1 year ago ·
11378

Very useful, thanks...

over 1 year ago ·
12243

Thank you, very useful!

over 1 year ago ·
12277

Awesome! I wonder, this works in vim also (brew vim) but only ALT left, right doesn't work, do you know why? thanks!

over 1 year ago ·
12406

Thank you. This worked well with my OSX 10.9 mac.

1 Feb 2014

over 1 year ago ·
13350

Thank you. I spent some time looking for a solution and your trick finally fixed my problem.

over 1 year ago ·
13565

Interestingly, this doesn't work for me. OPTION+LEFT still gives [D, OPTION+RIGHT still gives [C. Are there any other possible sources of conflict beyond the general keyboard settings and profile keys?

over 1 year ago ·
13974

Why did I allow myself to continue living without this for so long?

over 1 year ago ·
14378

Thanks. Succint and clear.

over 1 year ago ·
14405

I would only add
alt + backspace : Send HEX "0x17"

https://code.google.com/p/iterm2/issues/detail?id=1052

over 1 year ago ·
15023

Thanks a lot mate! I went through quite a few blogs before this one worked for me!

over 1 year ago ·
15191

Thanks, just what I was looking for! :)

over 1 year ago ·
15817

Thank you very much; just landed on a mac and it was one of the biggest pain in the neck.

over 1 year ago ·
16231

Thank you very much!

over 1 year ago ·
16259

Awesome

over 1 year ago ·
16908

Thanks, that saved lots of time!! :D

over 1 year ago ·
17326

googled "iterm skip words"... first result and does what I need. thank you!

over 1 year ago ·
17500

This is great!

over 1 year ago ·
17678

Thanks really helpful

over 1 year ago ·
18120

Thank you, saved lots of time :)

over 1 year ago ·
18332

fantastic! woot!

over 1 year ago ·
18355

love it

over 1 year ago ·
21407

This has been driving me crazy since I switched to a Mac. Thank you SO MUCH! :)

over 1 year ago ·
21469

On Terminal.app: Settings->Keyboard->"Use Option as Meta key".
"Alt-." is my favourite. Repeat the last word of the previous command.

over 1 year ago ·
22116

In case anyone is still looking for a solution to this and lands here, you may need to edit your ~/.inputrc as well:

"\e\e[C": forward-word
"\e\e[D": backward-word
over 1 year ago ·
22153

Wow! Just installed iTerm2 and can't stop admiring it! It's like the best thing that happened in my programming life since vim!

over 1 year ago ·
22539

Thank you! =)

over 1 year ago ·
22554

Neat, now I finally can convert to Iterm 2!

over 1 year ago ·
22622

Nevermind... was looking at "Keys" and not "Profiles > Keys"

over 1 year ago ·
22653

Nice ..
Thanks for this trick !!

over 1 year ago ·
22766

This was the one thing that was driving me crazy when switching to iTerm. Thanks for posting!

over 1 year ago ·
24833

Thank you so much!

over 1 year ago ·
25061

Beautiful and needed. thank you

over 1 year ago ·
25300

This made me go back to Terminal (Yosemite). Total waste of time in iTerm2.
Thanks anyways for sharing this!

K

over 1 year ago ·
26351

Why wouldn't they have this by default... I just installed iterm2 and use option-left/right all the time and if I hadn't found this page I may have scrapped it.

over 1 year ago ·
27367

alternative option + f or option + b

over 1 year ago ·
27401

i really do not get, why this isn't preset in iterm. anyway, if you change the alt key behaviour, access to pipe | and others is gone too. so not really a solution afais?

over 1 year ago ·
27457

I did this and also edited my inputrc and moving left by one word works just fine but trying to skip right instead prints "ord-right". Any ideas what's going wrong here?

over 1 year ago ·
28671

nice!

over 1 year ago ·
29173

Quick and easy. Thanks!

over 1 year ago ·
29693

This is such an amazingly useful trick, it really ought to be a default settings. Thanks a lot!

8 months ago ·
29735

Isn't it a default now? I have these sequences already prefilled:
option + left: send hexcode 0x1b 0x1b 0x5b 0x44
option + right: send hexcode 0x1b 0x1b 0x5b 0x43

7 months ago ·