Movement by subwords
This PR adds commands that enable movement within subwords that are snake_cased or camelCased, as previously proposed in discussion https://github.com/helix-editor/helix/discussions/5463. Subwords are delimited by underscores and by transitions from lowercase to uppercase.
The commands are named {move,extend}_{next,prev}_sub_word_{start,end}. This PR doesn't add any keybinds.
Example usage (| characters indicate cursor):
|f|oo bar baz-> move next sub word ->|foo |bar baz|f|oo_bar_baz-> move next sub word ->|foo_|bar_baz|f|ooBarBaz-> move next sub word ->|foo|BarBaz
Example keybinds:
[keys.normal]
W = 'move_next_sub_word_start'
B = 'move_prev_sub_word_start'
E = 'move_next_sub_word_end'
[keys.select]
W = 'extend_next_sub_word_start'
B = 'extend_prev_sub_word_start'
E = 'extend_next_sub_word_end'
I notice many PRs have been marked with S-waiting-on-review but this one hasn't, is there anything I need to do to request a review?
Can confirm this works as advertised. Thanks, I was literally making the same change and decided to look for a PR first.
My only concern is the widespread use of "char_is_word". I wonder in what other ways the definition of "word" is not matching "subword". Many of the places there is little context, just a solitary character.
Initially I thought Grapheme::is_word_boundary might be a good avenue but that is only used in doc formatting for some reason....
It's been a while since I implemented this, so I can't remember whether I looked at char_is_word. There is at least one other definition of "word" that I didn't update, which is in text objects. Meaning miW is still Match inner WORD, instead of Match inner sub word. Sub word text objects are implemented in #8658 though, if you need them.
That being said, I've been using this branch in my daily driver since I created it, and so far everything works as expected, so I don't think char_is_word is too important. If the core devs are interested I can work on this as well, but for now, I tried to keep the diff as small as possible (except for the tests) so that I can easily keep up with master.
Friendly ping to @the-mikedavis to request a review, since this PR already got one approval and is relatively small (ignoring the tests)