Sublime Forum

How to replicate "move by subwords" behavior on single text point

#1

Sublime contains keybindings like this:

{ "keys": ["alt+left"], "command": "move", "args": {"by": "subwords", "forward": false} },
{ "keys": ["alt+right"], "command": "move", "args": {"by": "subword_ends", "forward": true} },

I would like to be able to replicate the same “move… by…” behavior on a single text point, but I don’t know how because I don’t know what “subwords” and “subword_ends” really mean, I just see the observed behavior.

One thing I could do, for example, to load my text point as the single Region of the current view, then run the appropriate command on the view, then reload my old regions, but this seems pretty clunky.

Does anyone know what “subwords” and “subword_ends” mean? Or a pre-existing API call that I can call on a view and a pt?

0 Likes

#2

There is information on the move command in the unofficial docs.

“move… by…” behavior on a single text point

Can you elaborate on this a bit more ?

0 Likes

#3

Currently if I do alt+left (with the keybinding shown in my first post), the caret jumps back a subword, though the behavior isn’t entirely clear to me because it chooses to swallow past extra characters at the beginning of the subword such as spaces, underscores, and quotes. (Though for example, it won’t jump past a quote followed by a space; then it will just move to before the space; the behavior is also slightly different in the forward and backward directions.)

Basically, I would either like to have access to the “raw” function that computes the next caret position from the original caret position, or else understand what exactly this function is doing, so that I could replicate it.

0 Likes