177

Is it possible to move between words in iTerm using Alt + Right/Left Arrows ? Now if I press Alt+Left I will get '[D' and '[C' if I press Alt+Right.

174

Go to iTerm Preferences → Profiles, select your profile, then the Keys tab. Click Load Preset... and choose Natural Text Editing.

  • 2
    This turns on word skipping, but using the cmd key, not the opt key (which is what all other apple apps use). – TheProletariat Oct 20 '18 at 1:34
  • 1
    In December 2018 on Mojave, the opt key is what moves between words after choosing natural text editing. – Rob Dawson Dec 16 '18 at 21:15
  • I've been suffering for months without this but today you're my saviour. – Raimi bin Karim Mar 15 at 3:00
158

Go to iTerm Preferences → Profiles, select your profile, then the Keys tab. Find ⌥← and ⌥→ and set them to send escape sequence b and send escape sequence f respectively.

Mapping alt-right to move cursor forward by one word

If you use ⌘→ and ←⌘ you will need to remap the next and previous tab shortcuts which are set to those as default. Terminal uses ⇧⌘→ and ⇧⌘← for these.

You can do this under Profiles, or just globally under Keys (shown below) if you wish to set it globally. Note that settings in Profiles override global settings in Keys.

Globally mapping alt-right to move cursor forward by one word

23

If you use bash, you can also add

"\e\e[D": backward-word
"\e\e[C": forward-word

to ~/.inputrc.

  • 1
    This worked best for me. Trying to set it up in iTerm2 only generated [D or [C each time I tried to use the new button action. Thank you. – dgig Jul 13 '16 at 17:35
  • As far as I can tell there's nothing you can do in iTerm2 v3.0.10. It has to be this bash setup. – fiorix Oct 3 '16 at 16:32
  • 1
    Not sure about iTerm2 v3.0.10, but iTerm2 v3.0.14 definitely works with the Natural Text Editing solution so you don't need to resort to bash input configuration. – dwanderson Feb 16 '17 at 18:45
8
  1. Go to: Preferences > Profiles > Keys

  2. Look for the actions of ⌥← and ⌥→. They would have been mapped to: Send Hex codes

  3. Change them to Send Escape sequence with Esc+B for backward and Esc+F for forward.

2

Late in the game but for the visual:

enter image description here

Namely, see the Esc+ is selected.

1

CMD+Delete -- Send Hex Code -- 0x15

To delete the whole line (similar to Option+U)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .