Tuesday, July 10, 2007

Skip to Next or Previous Word in iTerm Using Alt / Option + Left or Right Arrow Keys

I recently decided to give iTerm another try after one of my friends recommended it to me. I had tried it several times before, and never quite gotten used to it. I always seemed to prefer Visor + Terminal for some reason or other, but since I've setup a global keyboard shortcut to focus / open iTerm, I've been enjoying having a tabbed terminal.

One of the things that was fairly easy to setup in Terminal that took me several days to figure out in iTerm was how to navigate Forward and Backword across whole words using the keyboard. ( This article on the Textmate blog explains how to set this up in the regular terminal. )

I tried doing all sorts of things to setup something similar in iTerm, like using a .inputrc file, until I finally figured out how to do it.

Open iterm.
Go to Bookmarks > Manage Profiles
Choose Keyboard Profiles on the left and edit the Global Profile



Map Alt + Left Arrow to Backword / Previous Word

Next to Mapping, click the + sign.
For Key, choose cursor left.
For Modifier, check the Option Box
For Action, choose send escape sequence
Write b in the input field.
I also checked High interception priority for good measure.

Map Alt + Right Arrow to Forward / Next Word

Next to Mapping, click the + sign.
For Key, choose cursor right.
For Modifier, check the Option Box
For Action, choose send escape sequence
Write f in the input field.
I also checked High interception priority here for good measure.



Now you have some sweet keyboard navigation action.

Bonus:
Beginning of Line: Ctrl + a
End of Line: Ctrl + e

5 comments:

Vaughn said...

Choose key = hex code and enter 0x62 for b and 0x66 for f to get the alt-f alt-b keys working.

Doppelganger said...

Beautiful. Thanks! Is there any way to delete a whole word with alt+delete, like in bash?

Chrsitian said...

Thanks! I never understood why every terminal application does this in its own way.

Matt Craig said...

Excellent! I'd been looking for a way to do this for a while.

Anonymous said...

lifan message boards suzuki 2006 gsxr 600 honda accord 2001 air bag for sale ca car haulers used auto lease residual calculator