How do I make option+left/rightarrow move the cursor one word at a time like in Terminal?

775 views
Skip to first unread message

Michael Marotta

unread,
May 4, 2015, 3:30:25 PM5/4/15
to iterm2-...@googlegroups.com
I use option+left/rightarrow in Terminal to move my cursor around quickly (one whole word at a time) but in iTerm it prints [D and [C. I went to Preferences>Profiles>Keys and tried deleted the option+arrows key combo, setting it to 'ignore', setting it to 'do not remap', changing the option key to meta or escape mode, and nothing changes, it still spits out [D. How do I get this to work like the normal mac cursor move for Terminal and all other text programs? 

Michael Marotta

unread,
May 4, 2015, 8:34:39 PM5/4/15
to iterm2-...@googlegroups.com
If there is no way is there some faster way to move the cursor around? When I have a very long command with many parameters it takes forever to arrow through it to edit something in the middle or beginning. Option+arrowing makes this so much faster. 

Pelle Johansson

unread,
May 5, 2015, 3:45:59 AM5/5/15
to iterm2-...@googlegroups.com
Hi,

you're looking for the "Left option key acts as +Esc" option, under "Keys" in the profiles. Or you can add mappings just for the arrow keys, but you will have to figure out the escape codes in that case.

Regards,
Pelle

Pelle Johansson

unread,
May 5, 2015, 3:55:45 AM5/5/15
to iterm2-...@googlegroups.com
Sorry that was wrong, all you need to do is bind it.

bind '"\e[1;9D": backward-word'
bind '"\e[1;9C": forward-word'

Not sure exactly how Terminal.app does it.

Rainer M Krug

unread,
May 5, 2015, 4:21:41 AM5/5/15
to iterm2-...@googlegroups.com
Use .inputrc

I have the following in my ~/.inputrc

,----
| # Unicode I/O
| set input-meta on
| set output-meta on
| set convert-meta off
| # Word jumping with CTRL left/right
| "\e[1;5D": backward-word
| "\e[1;5C": forward-word
| # Line limits jumps SHIFT CTRL left/right
| "\e[1;6D": end-of-line
| "\e[1;6C": beginning-of-line
`----

I don't know where the wiki with the details is after the googlecode
shutdown.

Hope this helps,

Rainer

Michael Marotta

unread,
May 5, 2015, 9:33:30 AM5/5/15
to iterm2-...@googlegroups.com
Pell, when you say I need to bind it how exactly do I do that? Is this something I do on the Keys preference page? ie Do I double click it and select one of the actions (Send Text?) and paste the whole bind line in? Or am I misunderstanding what to do with these. 

Per Johansson

unread,
May 5, 2015, 9:43:17 AM5/5/15
to iterm2-...@googlegroups.com
Hi,

You type it in the shell.

If you want to save it permanently, do like Rainer said, and put it in .inputrc in your home folder (note that you skip the bind keyword and the single quotes there).

Regards,

-- 
Per Johansson

--
You received this message because you are subscribed to a topic in the Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iterm2-discuss/kDK_N0QpsEo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iterm2-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Marotta

unread,
May 5, 2015, 10:13:08 AM5/5/15
to iterm2-...@googlegroups.com
Ah, thanks!
Reply all
Reply to author
Forward
0 new messages