Reputation: 3387
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?
Upvotes: 3
Views: 584
Reputation: 172590
If this is just for navigation, my camelcasemotion plugin provides alternative ,w
/ ,b
/ ,e
motions (and corresponding text objects), but leaves Vim's word definition alone; i.e. you can still change the entire variable_name
via iw
. Alternatively, you can also override Vim's built-in motions with the ones from the plugin.
Changing 'iskeyword'
(as suggested by @Rob) may affect syntax highlighting and other plugins, so this would be a less intrusive solution.
Upvotes: 3