Home Download Buy Blog Forum Support

Override specific auto-pair?

Override specific auto-pair?

Postby charlesroper on Mon Jul 18, 2011 7:32 pm

What's the best way of overriding a specific auto-pair in a given syntax? For example, I don't want curly braces to auto-pair, but I want the rest to work as normal.

Thanks in advance.
charlesroper
 
Posts: 107
Joined: Thu Feb 18, 2010 7:30 am

Re: Override specific auto-pair?

Postby guillermooo on Mon Jul 18, 2011 8:04 pm

If you want to restrict the override to one particular scope, I suppose you could define new key bindings for that particular scope.

Code: Select all
   {
      "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0" },
      "context":
      [
         { "key": "selector", "operator": "equal", "operand": "source.css" }
      ]
   }


Probably you can use a sort of "insert_text" command instead of "insert_snippet", but I can't find it now if it exists --using the latter seems unecessary. It might need a fair bit of fine-tuning to make it play well with other key bindings, and it might not work at all, because I haven't tested it, but that's my gut feeling about this.
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Override specific auto-pair?

Postby charlesroper on Mon Jul 18, 2011 8:52 pm

I ended up recording a macro:

Code: Select all
[
   {
      "args":
      {
         "contents": "{$0}"
      },
      "command": "insert_snippet"
   },
   {
      "args": null,
      "command": "right_delete"
   }
]


and then overrode the keybinding:

Code: Select all
[
  { "keys": ["{"], "command": "run_macro_file", "args": { "file": "Packages/Jinja2/Cancel curly brace auto-pair.sublime-macro" } }
]


Seems to work.
charlesroper
 
Posts: 107
Joined: Thu Feb 18, 2010 7:30 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 13 guests