Control+ArrowKeysNotWorkingiTerm2MacOS
If you have recently switched to MacOS and started using iTerm2 as your terminal emulator, you might have noticed that the default keyboard shortcuts for navigating the command line using Control+Arrow keys don't work as expected.
Default behavior of Control+Arrow keys in iTerm2
By default, iTerm2 is configured to use the option key instead of the control key for navigating the command line. This means that when you press Control+Left Arrow, iTerm2 will interpret it as option+Left Arrow and move the cursor to the previous word instead of moving it one character to the left.
Changing the behavior of Control+Arrow keys in iTerm2
To change the behavior of Control+Arrow keys in iTerm2, you need to modify the keyboard shortcuts in the preferences. Here's how to do it:
- Open iTerm2 and go to
Preferences > Profiles > Keys. - In the
Keystab, click on the+button at the bottom to add a new keyboard shortcut. - In the
Keyboard Shortcutfield, press theControl+Left Arrowkeys to record the shortcut. - In the
Actionfield, selectSend Escape Sequencefrom the dropdown list. - In the
Escape Sequencefield, enterAforControl+Left Arrow,BforControl+Right Arrow,CforControl+Up Arrow, andDforControl+Down Arrow. - Click on the
OKbutton to save the changes.
After following these steps, the Control+Arrow keys should work as expected in iTerm2.
Alternative solution: Using a different terminal emulator
If you prefer not to modify the keyboard shortcuts in iTerm2, you can consider using a different terminal emulator that supports the default Control+Arrow keys behavior. One such terminal emulator is Terminal.app, which is the default terminal emulator in MacOS.
- By default, iTerm2 uses the
optionkey instead of thecontrolkey for navigating the command line. - To change the behavior of Control+Arrow keys in iTerm2, you need to modify the keyboard shortcuts in the preferences.
- An alternative solution is to use a different terminal emulator that supports the default Control+Arrow keys behavior, such as
Terminal.appin MacOS.