ds2dha
Last Updated: April 28, 2017
·
30.41K
· levitanong

Word/Line deletion and navigation shortcuts in iTerm2

In OSX, ⌥+⌫ and ⌘+⌫ are the shortcuts for deleting a word and deleting a line respectively. ⌘+ ← and ⌘+ → are for going to the beginning and end of lines. By default, iTerm2 isn't configured this way, and there are a lot of misleading guides online. The following is what I've found to work on my machine.

  1. Open the preferences (⌘+,) and go to the Keys tab.
  2. Add a global shortcut key, and just type in your shortcut
  3. In the Action dropdown, select Send Hex Code

The hex codes for...

  • Deleting a word: 0x17.
  • Deleting a line: 0x15.
  • Moving to the beginning of the line: 0x01.
  • Moving to the end of the line: 0x05.

Just open a new tab, and it should work!

Here is a screenshot, for clarity.
Picture

Sources:
http://stackoverflow.com/questions/15733312/iterm2-delete-line

Steven Lu for deleting a line

Carlos for deleting a word
http://apple.stackexchange.com/questions/89981/remapping-keys-in-iterm2
` for navigating lines

EDIT: I've added code for beginning and end lines, and i'm currently working on turning this into a nice, complete list.

7 Responses
Add your response

14134

Thanks! It was helpful!

over 1 year ago ·
18049

great tip.

over 1 year ago ·
18203

Any ideas how to delete line forward and delete word forward?

over 1 year ago ·
18230

I found a useful post in stackexchange, and I'll integrate some of that information into this protip (with references of course) http://apple.stackexchange.com/questions/89981/remapping-keys-in-iterm2

In short, instead of selecting "Send Hex Codes", select "Send Escape Sequence", and just type "d".

over 1 year ago ·
19468

deleting a word should actually be hex code 0x1B 0x08
this will delete up to punctuation.

over 1 year ago ·
19502

Alternatively, this exists initially:

Ctrl+a = move to the begging of the line

Ctrl+e = move to the end of the line

over 1 year ago ·
20115

Amazing! I did not know this before you brought it up.

over 1 year ago ·