Home Download Buy Blog Forum Support

Auto-Pair Quotes

Auto-Pair Quotes

Postby Allen on Wed Feb 10, 2010 3:24 pm

I have been hand coding everything for years and am not at all used to my editor automatically completing quote and bracket pairs as I'm typing . . . I am curious, before I just disable that functionality, how other people use it. I must be overlooking something. I don't find it saves me any keystrokes ( I still have to use arrow keys or the way-on-the-other-side-of-the-keyboard End key to get out of the quote pair, so if anything it's just pre-emptively preventing me from leaving it open. Perhaps there's a "Hey I'm done, get me out of here" keystroke, to go from inside the pair to outside, but barring that . . . what is the utility to auto pairing quotes and brackets? It just drives me batty, personally.
Allen
 
Posts: 43
Joined: Sun Jan 24, 2010 2:50 pm

Re: Auto-Pair Quotes

Postby EJ12N on Wed Feb 10, 2010 4:31 pm

so if anything it's just pre-emptively preventing me from leaving it open.

That's one reason. Also not always your typing quotes and then you continue typing. Also this works with selections so if you want to quote something really quick just select and type a quote it'll wrap the selection in quotes. If you are used to the habit of just inserting the quotes manually u can have that without disabling the functionality because if you do insert a quote while there's another quote in front it will just jump forward (right arrow functionality). I mean I really don't see any disadvantage from a productivity point of view but I might be wrong. On the contrary I see it speeds up your productivity a bit. :)


However here's how to disable it...

Menu > Preferences > User file preferences:
Insert the following
Code: Select all
# Set to false to stop auto pairing quotes, brackets etc
autoMatchEnabled false
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: Auto-Pair Quotes

Postby Allen on Wed Feb 10, 2010 7:54 pm

So it doesn't seem I'm really missing much, in terms of working with it -- it just doesn't fit into my work flow too well. In my case, because I am so accustomed to closing them myself, I find I actually end up having to manually clean up afterwards. It's not such a big deal with the quotes but with the brackets, when they are added with new lines etc.
Allen
 
Posts: 43
Joined: Sun Jan 24, 2010 2:50 pm

Re: Auto-Pair Quotes

Postby GreyWyvern on Wed Feb 10, 2010 9:56 pm

I find the main disadvantage to disabling the auto-pair quote function is stressing out your syntax highlighting. This is especially obvious if you are editing large files with plenty of text after the cursor. If you type one quote, and it's not auto-paired, there is a noticeable delay while the rest of the document is checked and then highlighted as a string. Once you add the second quote, the rest of the document returns to normal.

With auto-pairing, the two quotes are inserted instantly and the highlighting stays sane. That being said, I've turned off auto-pairing of quotes as well due to conflicts with my muscle-memory ;)
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: Auto-Pair Quotes

Postby jps on Wed Feb 10, 2010 10:04 pm

GreyWyvern wrote:If you type one quote, and it's not auto-paired, there is a noticeable delay while the rest of the document is checked and then highlighted as a string.


This should no longer be as issue after the 20091113 beta, as syntax highlighting will no longer be evaluated past what's visible. There are still speed benefits to auto pairing quotes, but hopefully not perceptible ones.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Auto-Pair Quotes

Postby EJ12N on Thu Feb 11, 2010 4:52 pm

well that's the beauty of sublime, it fits everybody and you can customize it to your specific needs and make it dance and sing to you all day if that's what you want :) it's a sublime experience :P
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: Auto-Pair Quotes

Postby guillermooo on Thu Feb 11, 2010 8:46 pm

I have defined the following keybinding for this very same thing:

Code: Select all
<binding key="p,p" command="move characters 1">
      <context name="allSelectionsEmpty" value="true" />
      <context name="allFollowingText" value="^[\)\]\}\>\.,;:'&quot;]" />
</binding>


Now every time I press the sequence "pp" before one of those characters, the cursor moves past them without me having to reach for the arrow keys.

Question: I haven't figured out yet how to escape a double quote... \" doesn't seem to work...

EDIT: Added &quot; as Jon suggests.
Last edited by guillermooo on Thu Feb 11, 2010 9:55 pm, edited 1 time in total.
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am

Re: Auto-Pair Quotes

Postby jps on Thu Feb 11, 2010 9:48 pm

guillermooo wrote:Question: I haven't figured out yet how to escape a double quote... \" doesn't seem to work...


You can use &quot;
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Auto-Pair Quotes

Postby cocoflunchy on Fri Apr 06, 2012 4:57 am

Hi, I'm feeling the same as Allen and guillermooo here about auto-pairing. So I tried to add the key binding that guillermooo suggested back in 2010, but it looks like the syntax has changed since then (or have I missed something ?).

Can you help me with this key binding ? It's not parsed correctly by ST2.
Code: Select all
{ "keys": ["p,p"], "command": "move characters 1", "context":
   [
      { "name": "allSelectionsEmpty", "value": true },
      { "name": "allFollowingText", "value": "^[\)\]\}\>\.,;:'&quot;]" }
   ]
}
cocoflunchy
 
Posts: 1
Joined: Fri Apr 06, 2012 4:31 am

Re: Auto-Pair Quotes

Postby shawnoster on Sun Apr 15, 2012 10:27 pm

What would make this work flow even better is the ability to "tab out" of the auto-matched quote/brace/bracket/ending mark. There is a plug-in for Visual Studio that does this and it's incredibly useful. When you get the point where you'd normally type another quote or right arrow you instead tab.

The productively comes from the fact that tabbing is much faster than either right-arrow or another closing character, many of which require a shift+combo. I think I've started one or two thread in these forums requeting this feature as have a few others. You don't know what you're missing until it's gone :)
shawnoster
 
Posts: 5
Joined: Fri Aug 12, 2011 9:16 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 27 guests