Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Claire Parker-Jones
Claire Parker-Jones

Posted on • Originally published atclairecodes.com on

     

Making the Alt Key Work in iTerm2

iTerm2 is a replacement for the default Terminal application on MacOS. It has many more handyfeatures than Terminal, is free to download and is alsoopen source 🎉.

However, on initial install, you can’t use the Option or Alt key (the one that looks like this:) as you would in other applications: it's not possible skip or jump over words by pressing Alt and the left or right keys. Instead you see sequences like[D or[C:

Broken alt key displaying escape sequences

This can be changed by tweaking a couple of settings, which I'll explain below.

Note: I refer to the"Alt" key throughout this post, as this is the text written on the key of my old 2013 MacBook Pro keyboard, but this is normally called the "Option" key in MacOS.


Open the "Preferences" menu: either find it in the "iTerm2" dropdown menu along the top of the screen or press the Command and comma keys. +,

iTerm2 general preferences menu

Choose the "Profiles" menu.

iTerm2 profiles menu

Select the "Keys" tab.

iTerm2 keys tab

Within the "Key Mappings" pane, find the mapping for the Alt and left keys, which will look like this:⌥←. Double click it.

iTerm2 keys tab with Alt Mappings

Change the action from "Send Hex Code" to "Send Escape Sequence" (you might have to scroll a bit to find this).

In the "Esc +" field, type lowercase "b" and click "OK".

iTerm2 Alt left mapping

Open the same context menu for Alt plus right⌥→ and again change the action to "Send Escape Sequence".

This time, in the "Esc +" field, type lowercase "f". Click "OK".

iTerm2 Alt right mapping

Close the Preferences menu. The changes take effect immediately. When you press + or, the cursor will jump over entire words as it does on other applications. You can now navigate the command line with more precision and speed.

Working alt key moving between words

Bonus shortcuts

Control +e will move the cursor to the end of the line.

Control +a will move the cursor to the beginning of the line.

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
oli8 profile image
Olivier
Web & Blockchain developer
  • Work
    Software Engineer @ Coddity & SFR
  • Joined

Thanks !

CollapseExpand
 
brutalsimplicity profile image
Kory Taborn
Bit Fiddler
  • Joined

yep, Thanks so much

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Frontend web developer
  • Location
    Warrington, UK
  • Joined

More fromClaire Parker-Jones

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp