Sublime Forum

Newline selection keymap

#1

hi all, I’m new in the sublime text,

I would like to create a keymap, which will move forward to the beginning of word in the next line, when i press Ctrl+Shift+Right in the End of Line.
The current state of the sublime text is, when I press Ctrl+Shift+Right in the end of line, it will move to the beginning of line in the next line, and I should press Ctrl+Shift+Right again to move to the beginning of word, and this behavior doesn’t seem efficient enough for me.

here is my code:

[code] { “keys”: “ctrl+shift+right”], “command”: “move”, “args”: {“by”: “subwords”, “forward”: true, “extend”: true},
“context”:

		{ "key": "following_text", "operator": "regex_contains", "operand": "\n", "match_all":true }
	]
},[/code]

I had read the documentation about context sublimetext.com/docs/contexts but had a hard time because there are no examples. I’ve tried with other character other than the newline character, and sublime seems can handle it correctly. so, any ideas?

thanks in advance

0 Likes

#2

The problem would appear to be the command you’re using: it’s the same command that alt+right arrow uses, which won’t do what you want. I suspect you’ll need to record a macro, and bind the key to run the macro (via the run_macro_file, of which there are examples in the default keymap)

0 Likes

#3

thank you for the kind answer.

actually I’m trying to emulate the end-of-line behavior from the e-texteditor.

you’re right, the problem lies within the ctrl+right action.
I have tried to implement this today: I tried to detect the next character using the “following_text” context (as in my first post), but it was unsuccessful when there are text-selection present.

eg:

lorem ipsum dolor sit amet
if the “ipsum dolor” text were selected, and the cursor is located in the beginning of the selection, the key binding will be correctly triggered, but the cursor will move not in the right way.

this happens because the context was based on the selection instead of cursor (i read the context documentation and mostly are triggered based on selection, and none on cursor).

please kindly cmiiw, as I’m still learning :smile:

0 Likes