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.

  • demas: Please choose the 2nd answer as the correct answer; selecting the Natural Text Editing key profile preset is now the most elegant solution. – Nick Bolton Jun 24 at 9:36
up vote 109 down vote accepted

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

  • 18
    This is the correct solution as of latest version. – sq2 May 17 '16 at 0:44
  • 2
    This option is not present in the last Iterm2 v.3.0.3. Under 'Load Preset' I only have factory defaults. – Innokenty Jul 1 '16 at 8:37
  • 6
    "Natural Text Editing" is available under Profile > Keys as a preset, but not under the global Keys settings. – Nick Sep 4 '16 at 22:14
  • For some reason I don't know. This doesn't work for me, still getting the strange symbols. Thanks though – coffekid Dec 6 '16 at 18:59
  • This is a much better answer for newer versions. Thank you! – Steve S Jun 29 '17 at 23:32

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

  • 2
    It doesn't work for me derp.co.uk/9a631 – demas Jul 3 '14 at 18:01
  • 2
    It works, thanks. But what does those escape sequences actually mean? – Disper Jul 22 '15 at 7:11
  • 31
    Shouldn't this be default in the OS X version of iTerm by now? – rcd Aug 6 '15 at 19:30
  • 4
    Important: you also need to go to Profiles > Keys and unbind same combinations there! Because this setting in profile is stronger and overrides the keys settings in the original answer. – Innokenty Jul 1 '16 at 8:36
  • 2
    @Innokenty The screenshot (edited into my answer by another user) does not follow the steps I describe in the words above it (written by me), the latter of which match what you suggest – grg May 6 '17 at 16:38

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
  • 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
  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.

  • This solution is better, than the accepted answer due to the reasons I've put in a comment on the latter. – Innokenty Jul 1 '16 at 8:39

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

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

Late in the game but for the visual:

enter image description here

Namely, see the Esc+ is selected.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.