With iTerm2 on Mac, how to delete forward a word from cursor on command-line?

qazwsx picture qazwsx · Sep 9, 2012 · Viewed 12.8k times · Source

With iTerm2 1.0.0 on Mac OS X 10.6.8, I'd like to delete from cursor to the next end of word, i.e. deleting one word forward. I tried Alt+d but this types the delta operator symbol and doesn't delete. How to suppress the typing but let it delete?

Answer

maxbellec picture maxbellec · Jun 9, 2016

For this and other shortcuts go to preference -> profile -> keys, add the following shortcuts

⌥← : Send Escape Sequence Esc+ b

⌥→ : Send Escape Sequence Esc+ f

⌘← : Send Escape Sequence Esc+ [H

⌘→ : Send Escape Sequence Esc+ [F

⌘←Delete : Send Hex Code 0x15

⌥←Delete : Send Hex Code 0x1B 0x08

http://elweb.co/making-iterm-2-work-with-normal-mac-osx-keyboard-shortcuts/ gave me the tip