Marius Schulz
Marius Schulz
Front End Engineer

Keyboard Shortcuts for Jumping and Deleting in iTerm2

As a software engineer, I find myself using the terminal every day to run all sorts of commands. My current terminal of choice is iTerm2 which I’ve been using happily for many years.

Whenever I set up iTerm2 on a new Mac, one of the first things I do is to configure familiar keyboard shortcuts for common navigation and edit actions in the command prompt. For example, I typically configure the shortcut which jumps me to the start of the word under the cursor.

To configure custom keyboard shortcuts in iTerm2, open the preferences dialog and navigate to the Profiles › Keys › Key Mappings tab:

iTerm2 Preferences: Profiles › Keys › Key Mappings

Click the “+” button to add a new key mapping, or double-click an existing key mapping to edit it. For the “Jump to start of word” command, select the “Send Escape Sequence” action and send the escape sequence Esc+b:

iTerm2 Preferences: dialog for editing a key mapping

Now, whenever you're typing a command in iTerm2, it's really easy to jump back to the start of the word (or even multiple words) to insert more text or delete part of the command — no more need for repeatedly pressing the key to navigate back character by character.

Here's the full list of keyboard shortcuts that I configure for various jump and delete commands:

Shortcut Command Action Send
Jump to start of word Send Escape Sequence b
Jump to end of word Send Escape Sequence f
Jump to start of line Send Hex Codes 0x01
Jump to end of line Send Hex Codes 0x05
Delete to start of word Send Hex Codes 0x17
Delete entire line Send Hex Codes 0x15