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.
- Open the preferences (⌘+,) and go to the Keys tab.
- Add a global shortcut key, and just type in your shortcut
- 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.
Steven Lu for deleting a line
Carlos for deleting a word
` 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.