Setting up the cursor movement keys in iTerm2 on OSX
This orginal post is from here.
iTerm2 is a nice, customizable terminal emulator for OSX, but the typical cursor movement keys (such as
⌘←
(Command-Left
) for “move to beginning of line and⌥→
(Option-Right
) for”move forward one word”) never seem to work for me out of the box.Here’s how to set them up (based on build 2.1.4 but works 3.4.22):
- Clear out any per-existing bindings for these short-cuts. There two different places to check–in the “global” keys and in the “profile” keys.
For the profile keys go to
Preferences
>Profiles
>Keys
>Key Mappings
and look for the⌘←
,⌘→
,⌥←
and⌥→
shortcuts (and delete them if found.)For the global keys go to
Preferences
>Keys
and look for the symbols in (and remove them from) the “Global Shortcut Keys”.
- In either the profile or global shortcut settings (your choice) add the shortcuts back in, with the following bindings:
Use
Send Escape Sequence
f
for “move forward one word”. On OSX, I bind this to⌥→
(Option-Right
) as that seems to be the convention other apps follow.Use
Send Escape Sequence
b
for “move backward one word”. On OSX, I bind this to⌥←
(Option-Left
).Use
Send Hex Code
0x05
for “move to end of line”. On OSX, I bind this to⌘→
(Command-Right
) as that seems to be the convention other apps follow.Use
Send Hex Code
0x01
for “move to beginning of line”. On OSX, I bind this to⌘←
(Command-Left
).Now these keys should work the way your muscle memory (or at least my muscle memory) expects them to.
In addition, as in iTem2, “next Tab” was bind to ⌘→
(Command-Right
), which has been replaced, I set up tab navigation as following:
Using
Next Tab
for “move to next tab”, I bind this⌥⌘→
(Option-Command-Right
)Using
Previous Tab
for “move to previous tab”, I bind this⌥⌘←
(Option-Command-Left
)
You can download this file for my keymapping file iterm2mapping.itermkeymap for iTerm2
Back to top