macOS comes with Emacs-style shortcuts by default.1 For example:
Control-B: Move one character backward.
Control-H: Delete the character to the left of the insertion point. Or use Delete.
Control-K: Delete the text between the insertion point and the end of the line or paragraph.
Try these anywhere and it just works. However, these are not good enough, because:
They’re only a subset of the readline bindings.2 In other words, the most useful Control-W (delete last word) is not there.
Control+B/F/P/N only works in text fields, while being immensely useful in many places outside of text fields. As a responsible Vim user, I hate arrow keys.
They does not work with Chinese input method (pressing Control+H exits from word selection mode instead of only deleting the last character).
Enter BetterTouchTool! BetterTouchTool allows you to create keyboard shortcuts globally for each application, and it perfectly solves the problem.
Therefore, just create bindings like these:
Until, you find out that a bunch of key bindings in your Vim (or VimR, or MacVim, or whatever) stopped working. Which is not a surprise as, now when you press Control-N, what iTerm2 gets is actually “Down”. Fortunately, we could create shortcuts local to one application to “shadow” the global bindings. In this case:
Use “Use Apple Default Or Do Nothing” to shadow out the global shortcut for iTerm2 (or anything else that actually needs those bindings).
Note: As of the time of writing (2019-02-24), BetterTouchTool is still suffering from a issue where shortcut switching sometimes lags behind application switching, so that sometimes the “shadowing” will not work and iTerm2 still gets Control-N as Down. See issue tracker. As a temporary workaround, in iTerm2, I manually mapped these bindings back to their control ASCII codes, e.g. “Option+Delete” -> “Control+W” (via its hex code 0x17, shown below).