Home Download Buy Blog Forum Support

Shortcut to move cursor out of parenthesis, quotes, brackets

Shortcut to move cursor out of parenthesis, quotes, brackets

Postby billted98 on Thu Feb 09, 2012 8:34 pm

Newb question here:

Is there a shortcut to move the cursor out of parentheses, quotes, brackets, etc? For example, in jQuery I type:
.on(
and it auto completes to this
.on()
with the cursor in between the parentheses.

Then I type
'
and it auto completes to this
.on(' ')
with the cursor in between the single quotes.

Then I type
click
and it now shows this
.on('click')
with the cursor to the right of the
k

Now, in order to get the cursor to the right of the last parenthesis to continue typing, I must press the right arrow key twice. Awful problem to have I know :) but it does take my right hand out of typing position. Is there a shortcut for this? Something more convenient? Like Cmd+Space or something? Or a way to define one? I looked at the Key Bindings in Preferences but couldn't figure it out. And I don't know what this technique is called, so had trouble finding it when searching on the web.

I'm on a Mac with Lion using Sublime Text 2 with ZenCode and Prefixr installed.

Thanks much.
billted98
 
Posts: 3
Joined: Thu Feb 09, 2012 8:22 pm

Re: Shortcut to move cursor out of parenthesis, quotes, brackets

Postby agibsonsw on Thu Feb 09, 2012 11:17 pm

Hello.

Ctrl-right (arrow) normally works for me, or press the End key to go to the end of the line.

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Shortcut to move cursor out of parenthesis, quotes, brackets

Postby C0D312 on Thu Feb 09, 2012 11:31 pm

Add the following to your user keybindings:
Code: Select all
{ "keys": ["enter"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [
        { "key": "following_text", "operator": "regex_contains", "operand": "^[)\"\\]]", "match_all": true },
        { "key": "auto_complete_visible", "operator": "equal", "operand": false }
    ]   
  },


Substituting "enter" with "tab" works well, too.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Shortcut to move cursor out of parenthesis, quotes, brackets

Postby gour on Fri Feb 10, 2012 9:06 am

C0D312 wrote:Substituting "enter" with "tab" works well, too.


Thanks. It works nicely, but I wonder why is such functionality not present out-of-the-box?


Sincerely,
Gour
gour
 
Posts: 8
Joined: Mon Jan 30, 2012 10:41 pm
Location: Croatia

Re: Shortcut to move cursor out of parenthesis, quotes, brackets

Postby billted98 on Tue Feb 14, 2012 8:48 pm

Thanks everyone. You got me close enough that I was able to figure it out.

@C0D312
For some reason the code you supplied wasn't making it work, but if I changed "enter" to "super+space" it now works. I found the "super" thing used in a bunch of the default settings. Maybe it's a Mac thing?

But anyway it's beautiful now! Space is just a space, and Cmd+Space moves the cursor to the end of the text on that line. Thanks so much!
billted98
 
Posts: 3
Joined: Thu Feb 09, 2012 8:22 pm

Re: Shortcut to move cursor out of parenthesis, quotes, brackets

Postby billted98 on Tue Feb 14, 2012 8:51 pm

I forgot the code:

Code: Select all
{ "keys": ["super+space"], "command": "move", "args": {"by": "subword_ends", "forward": true} }
billted98
 
Posts: 3
Joined: Thu Feb 09, 2012 8:22 pm

Re: Shortcut to move cursor out of parenthesis, quotes, brackets

Postby rafrand on Tue Sep 25, 2012 3:41 pm

Hey

Just posting this for anyone that comes across this beginner issue. Just type the ending ' and it will jump you out of the 'example' grouping. Same goes with [] or (). Sublime highlights these so when you are typing it does the syntax highlighting.
rafrand
 
Posts: 1
Joined: Tue Sep 25, 2012 3:38 pm

Re: Shortcut to move cursor out of parenthesis, quotes, brackets

Postby highend on Tue Sep 25, 2012 4:26 pm

@C0D312

Is it possible to alter your keymap commands to something that works even when I move the cursor back in a section that is enclosed by quotes?

Atm I can only get behind one of the chars in your regex when I'm actually in such a block, not when I use the assigned keyboard shortcut to get out of it and move back via e.g. the cursor keys (or click with the mouse).
highend
 
Posts: 94
Joined: Fri Jan 20, 2012 2:47 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 23 guests