ds2dha
Last Updated: April 28, 2017
·
21.93K
· levitanong
9c9aa9f7e8ba18dac52f3cb4703ffb9e

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.

Say Thanks
Respond

7 Responses
Add your response

14134
17d4b07f7c71ced46348c741644383c3

Thanks! It was helpful!

over 1 year ago ·
18049

great tip.

over 1 year ago ·
18203
None

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

over 1 year ago ·
18230
9c9aa9f7e8ba18dac52f3cb4703ffb9e

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
None

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

over 1 year ago ·
19502
2c90565e7c155dd15310869d0396d334

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
9c9aa9f7e8ba18dac52f3cb4703ffb9e

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

over 1 year ago ·
Awesome Job

0957a9c2 0855 11e8 909a 82469fe19f14
Senior Backend Engineer
·
San Francisco, California
·
Full Time