I'm trying to remap option-backspace behave in vim in Mac OS X's Terminal app similarly to how it would behave in other Mac applications.
It should perform a backwards delete word, also deleting any leading whitespace characters.
The closest match I've been able to find so far is the
db command, but this only deletes to the beginning of the word; it does not remove any leading whitespace.
Here are some examples of what I am trying to accomplish (
| is the cursor position):
test text| here " After hitting option-backspace: test| here test text |here " After hitting option-backspace: test| here high-lighting| text " After hitting option-backspace: high-| text midway throu|gh text " After hitting option-backspace: midway|gh text start |of line " After hitting option-backspace: |of line
I initially was going to do
dbdh, but in the case of the third example, this would not work (the hyphen character is not whitespace, so it should be preserved).
Is there a good way to accomplish this?
EDIT: After doing some more typing, I realized that the "delete leading whitespace" behavior is actually not Mac-like; on my Mac, pressing option-backspace stops at the first non-word character, just like Vim does.
Thank you for joining me on this thought experiment, though (: