Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to redefine the meaning of "word" in vim?

Tags:

vim

In vim, string seperated by "-" would be treated as multiple words, so if I name a variable like 'this-is-a-very-long-variable-name', then vim treat that variable name as two words, so I can easily locate to the start or ending of "variable" and "name".

However, in most programming languages, I am not allowed to name a variable like that, the only programming language that support and prefer that name style is Lisp. in most other programming language, I have to use "_" instead.

So, if I have a variable named "this_is_a_very_long_variable_name", is there any way that I could move on that variable name by pressing "w/b/e" to move by word instead of pressing "h/l" to move by characters?

like image 760
Alaya Avatar asked Sep 13 '25 22:09

Alaya


1 Answers

You can change how words behave with iskeyword

:set iskeyword-=_
like image 54
Rob Avatar answered Sep 16 '25 12:09

Rob