How can I remap alt+backspace
to delete words like native *NIX text manipulation? I checked out this thread: Using alt+backspace key in vim command line to delete by words
And the examples like: cmap <a-bs> <c-w>
and :imap <A-BS> <C-W>
don't do anything. And the accepted answer was actually to not even remap it, but to use ctrl+w
. Since VIM's alt+backspace
doesn't do anything I'd rather remap it to something I'm used to.
I'm using terminal based VIM (specifically in iTerm)
The Alt/Meta key is problematic in Vim and most terminals, see this answer of mine for an overview of the situation (the situation is the same for Meta
and Alt
).
In short, Vim doesn't receive Alt
at all: hitting Alt+Backspace
is exactly the same as hitting Backspace
.
Anyway, it will be better for you in the long term to learn and get accustomed to Vim's default key-mappings.
On macOS with iTerm2, I have the option keys mapped to +Esc (like many people), and I found that pressing Option+Backspace actually was interpreted by vim as an Escape press followed by a Backspace press, so the following binding worked perfectly for me; I recommend trying it even if your configuration is different than mine, just in case it works for you!
:imap <Esc><BS> <C-w>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With