h6yfda
Last Updated: August 06, 2017
·
92.07K
· e-dard
A0c0f9fb28ae6e4a52a3d95c8f347432

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.

Say Thanks
Respond

40 Responses
Add your response

7441
890ea3e605528fb62f0e3b51866e0dc5

thx for the trick :)

over 1 year ago ·
11378

Very useful, thanks...

over 1 year ago ·
12243
6f50a256b89d3d264a9445528541e521

Thank you, very useful!

over 1 year ago ·
12277
Cbe57f486946b96f3e7d5187c4fced56

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
22a750f757d230bade8d64d15f584035

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

1 Feb 2014

over 1 year ago ·
13350
B28999d37d7f19ad1750a07b87cf0afa

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

over 1 year ago ·
13565
B0b05407bf5fe02b6563b0fb39be46b4

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
9d4b5c7e21b439738fbdedda94314734

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
3e52f57c4e6512a7c5a948d7f09d6503

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

over 1 year ago ·
15191
9e30e530d528a000975b7c25c42118be

Thanks, just what I was looking for! :)

over 1 year ago ·
15817
6adf28ad9319c969cfccca9d97453359

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
A69ccd99c8ef0be30b5dc870d7c8e9f8

Thank you very much!

over 1 year ago ·
16259
74311ccfa81176b0821d5e01e40b060f

Awesome

over 1 year ago ·
16908
None

Thanks, that saved lots of time!! :D

over 1 year ago ·
17326
Me normal

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

over 1 year ago ·
17500
None

This is great!

over 1 year ago ·
17678
None

Thanks really helpful

over 1 year ago ·
18120
Img 0099

Thank you, saved lots of time :)

over 1 year ago ·
18332
None

fantastic! woot!

over 1 year ago ·
18355
None

love it

over 1 year ago ·
21407
None

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

over 1 year ago ·
21469
None

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
None

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
019533bbd162b35aaf403145491843c1

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
69fb63c4f6819872bf0010b24194a73a

Thank you! =)

over 1 year ago ·
22554
9359760602e36ed0e43ff61a14f1812d

Neat, now I finally can convert to Iterm 2!

over 1 year ago ·
22622
None

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

over 1 year ago ·
22653
None

Nice ..
Thanks for this trick !!

over 1 year ago ·
22766
None

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

over 1 year ago ·
24833
0 fiun3egi64ebhhzr5ssl3i2qorsneskrlw7d3oxczom5bdpuwdws7eijxvdeie5c6hmeasslnlq9

Thank you so much!

over 1 year ago ·
25061
182ec4df5cfc9285908e29aaa0273812

Beautiful and needed. thank you

over 1 year ago ·
25300
Kalpesh panchal

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
None

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!

6 months ago ·
29173

Quick and easy. Thanks!

12 days ago ·
Filed Under