The plugin CamelCaseMotion does what you want. By default it maps to the keys ,w
, ,b
, ,e
which are equivalent to normal w
, b
, e
. It works for both CamelCase and snake_case:
Example:
camelCaseWord
Using d,w
will remove camel
; using it again will remove Case
.
Or with snake case:
snake_case_word
d,w
will remove snake_
, and on the second time it will remove case_
.
"Inner" motions (such as diw
) should also work as expected (as di,w
).
If you prefer, you could also override the default w
, b
, and e
with:
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
sunmap w
sunmap b
sunmap e
omap <silent> iw <Plug>CamelCaseMotion_iw
xmap <silent> iw <Plug>CamelCaseMotion_iw
omap <silent> ib <Plug>CamelCaseMotion_ib
xmap <silent> ib <Plug>CamelCaseMotion_ib
omap <silent> ie <Plug>CamelCaseMotion_ie
xmap <silent> ie <Plug>CamelCaseMotion_ie
snake_case
iskeyword
setting, but I fear this will have many additional side-effects ... (see:help word
).snake_case
. Seems that it doesn't, included it in the quesiton.f
andt
keys to manage inner word movements.