The semantics of
wWbBeEgegE are not as clearly cut as one would hope. The way they work mostly matches the way they are described in the documentation when the cursor is on the first character of a
WORD but it deviates quickly if that condition is not met or when used in combination with operators (think
I have had mixed feelings about that situation for years, adding mappings one day only to remove them the next day… and adding them back a couple of months later. I eventually settled on leaving the default behavior as-is and stop worrying about inconsistencies.
If you still want to enforce consistency over portability, I recommend using visual mode to preposition the cursor. It seems less brittle than just using
nnoremap b viwo<C-c>b
nnoremap B viWo<C-c>B
Note that normal mode mappings won't be enough as those motions can also be used in visual mode (
vb) and operator-pending mode (
yB). It would be a shame to chase consistency in one mode only.
xnoremap b <C-c>m'viwob<C-c>v``
xnoremap B <C-c>m'viWoB<C-c>v``
onoremap b :<C-u>normal vb<CR>
onoremap B :<C-u>normal vB<CR>
eEgegE are a little bit more complicated. On one hand,
eE are relatively clearly meant to move the cursor within a word, on the other hand
gegE can only move the cursor to another word despite the wording of their doc being pretty much copy-pasted from
eE. In my opinion,
gegE don't deserve custom mappings because their behavior is the least ambiguous of the lot, but their documentation should be improved. That leaves
eE, which you can decide to leave as-is or map like
Assuming you also decide to map
eE, you may notice that you can't move the cursor to the beginning or end of the current
WORD anymore, something that was precisely allowed by the "instability" of
bBeE. That's fine if you never need that feature, I guess, but that whole approach—modifying default behaviors and removing functionalities—is not one I would recommend.
e) or the beginning (for key
b) of the word, why would you want a keypress to keep you there? Just don't press any key then.