Mind you, cw
has a bit 'unstandard' behavior by default in that it is behaves exactly like ce
: It only works up until the end of the current word (like e
, ce
, de
, ye
) instead of including the whitespace up before the beginning of the next word (like w
, dw
, yw
).
Therefore I recommend adding these mappings to your vimrc
:
" Have `cw` adhere to its actual movement `w`, instead of duplicating `ce`.
nnoremap cw dwi
nnoremap cW dWi
and getting used to usually using ce
. Typing ce is actually more efficient and less awkward than cw if you form the habit of pressing the e with your ring finger instead of middle finger when it comes right after c.
If you prefer to leave cw
with its default assignment duplicating ce
, then you can access its 'proper' functionality with an additional keystroke: dwi
(or vwc
).
(Mind you, I find dwi
even more efficient to type than cw
because of the positions of the keys, in spite of the additional key.)
Explanation of the second mapping: W
(Shift+w) works on what vim calls "WORDS", which counts every non-blank character, e.g. punctuation, as part of a WORD; while w
works on "words", which only consist of uninterrupted sequences of letters, digits and underscores (by default).