Previously, I was setting my custom normal binds and select binds to the same thing. This made sense for almost everything. But, it turns out, for my word-moving binds, they're actually different. For normal mode, they have to look like this:
w = "move_next_word_start";
W = "move_prev_word_start";
e = "move_next_long_word_start";
E = "move_prev_long_word_start";
b = "move_next_word_end";
B = "move_prev_word_end";
n = "move_next_long_word_end";
N = "move_prev_long_word_end";
While with select, they have to look like this:
w = "extend_next_word_start";
W = "extend_prev_word_start";
e = "extend_next_long_word_start";
E = "extend_prev_long_word_start";
b = "extend_next_word_end";
B = "extend_prev_word_end";
n = "extend_next_long_word_end";
N = "extend_prev_long_word_end";
Notice the difference? For the selection binds to extend the selection, they have to use separate internal commands. Totally understandable. However, it's led to a lot of duplicated code between the two modes. Ideally, we'd be able to keep everything between the modes the same, except these two.
My immediate ideas for doing this are
Using a function that prepends move and extend to the given binds.
Declaring everything that's shared separately, and then using // to combine that with the mode-specific stuff
Writing it as a function feels like the right way to do this, but the simplicity of using // is really calling to me. However, if we ever get into nested binds, // will cause issues, and we really don't need to introduce some deepMerge stuff. I think if we write the function in the right way, it'll be great. We just need to figure out what that right way is.
Previously, I was setting my custom
normal
binds andselect binds
to the same thing. This made sense for almost everything. But, it turns out, for my word-moving binds, they're actually different. For normal mode, they have to look like this:While with select, they have to look like this:
Notice the difference? For the selection binds to extend the selection, they have to use separate internal commands. Totally understandable. However, it's led to a lot of duplicated code between the two modes. Ideally, we'd be able to keep everything between the modes the same, except these two.
My immediate ideas for doing this are
move
andextend
to the given binds.//
to combine that with the mode-specific stuffWriting it as a function feels like the right way to do this, but the simplicity of using
//
is really calling to me. However, if we ever get into nested binds,//
will cause issues, and we really don't need to introduce somedeepMerge
stuff. I think if we write the function in the right way, it'll be great. We just need to figure out what that right way is.