Home Download Buy Blog Forum Support

newline selection keymap

newline selection keymap

Postby adrianliem on Sun Jul 24, 2011 2:06 am

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: Select all
   { "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 }
      ]
   },


I had read the documentation about context http://www.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
adrianliem
 
Posts: 4
Joined: Sun Jul 24, 2011 1:51 am

Re: newline selection keymap

Postby jps on Sun Jul 24, 2011 2:24 am

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)
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: newline selection keymap

Postby adrianliem on Sun Jul 24, 2011 5:48 pm

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:
Code: Select all
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 :)
adrianliem
 
Posts: 4
Joined: Sun Jul 24, 2011 1:51 am


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 26 guests