Home Download Buy Blog Forum Support

auto_match_enabled without ignoring quotes before end quote?

auto_match_enabled without ignoring quotes before end quote?

Postby Johannes on Tue Jul 09, 2013 10:28 am

I like the automatic pairing of quotes, brackets, parentheses, etc. via auto_match_enabled = true in the settings.

However I often find myself being thrown off when I have my cursor to the immediate left of the closing quote, and attempt to type another quote. Instead of adding a new quote character, Sublime text sees that there is a closing quote, and just shifts the cursor to the right of the quote.

I find this second mechanic incredibly unintuitive, and it gives me problems especially when I'm working with lots of nested quotes/brackets, or when I want to set up nested parentheses. It can even feel like I'm fighting the program. I realize that with the correct workflow this shouldn't happen, but I guess it's just not how I work.


I was wondering, is there a way to disable this? I like that it auto completes the quote in the first place, but I don't like when it prevents me from starting a new quote to the immediate left of a closing quote character.
Johannes
 
Posts: 18
Joined: Sun Dec 11, 2011 1:44 am

Re: auto_match_enabled without ignoring quotes before end quote?

Postby quodlibet on Tue Jul 09, 2013 12:51 pm

You can override any binding from `Default ({your os}).sublime-keymap` in your User folder. The relevant section is at lines 278 or so and ff.

I'm not 100% sure I've understood what you want to happen. Here's what I think you want:

Code: Select all
(|) -> ((|))


With the | standing in for the cursor.

If so, here's what you would use:

Code: Select all
    { "keys": [")"], "command": "insert_snippet", "args": {"contents": "($0)"}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true }
        ]
    },


I'm using the parenthesis as an example because it makes it reasonably clear what's going on. You would need to replicate & modify this snippet for the `"`, `[`, `{` and `'`.

If there's a simpler way to override the bindings, I don't know it :)

Hope this helps,
Alex
quodlibet
 
Posts: 524
Joined: Sat Jun 18, 2011 5:53 pm


Return to Technical Support

Who is online

Users browsing this forum: dubeg, Yahoo [Bot] and 12 guests