Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customising word separators in vi

Tags:

vi

editor

Is there a way to add underscore _ as well?

:set iskeyword-=_ 

In case you're using vim, you can change that by setting the iskeyword option (:he iskeyword). If that is not an option, you can always use ct_ instead of counting.


One other good option in such cases is to use camelcasemotion plugin.

It adds new motions ,b, ,e, and ,w, which work analogously with b, e, and w, except that they recognize CamelCase and snake_case words. With it you can use

c,edest

and this will replace "src_branch" with "dest_branch" if your cursor was on first character of "src_branch".


You could type cf_dest_ and save the counting part.

Edit: or as suggested: ct_ changes text until right before the underline character. (I'm using the f motion more, so it came more naturally to me)

Or you could redefine 'iskeyword' (:help iskeyword for details).