Search code examples
editorvi

Customising word separators in vi


vi treats dash - and space   as word separators for commands such as dw and cw.

Is there a way to add underscore _ as well?

I quite often want to change part of a variable name containing underscores, such as changing src_branch to dest_branch. I end up counting characters and using s (like 3sdest), but it would be much easier to use cw (like cwdest).


Solution

  • 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.