Sublime Forum

Override specific auto-pair?

#1

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.

0 Likes

#2

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

[code] {
“keys”: “{”], “command”: “insert_snippet”, “args”: {“contents”: “{$0” },
“context”:

		{ "key": "selector", "operator": "equal", "operand": "source.css" }
	]
}[/code]

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.

0 Likes

#3

I ended up recording a macro:

{ "args": { "contents": "{$0}" }, "command": "insert_snippet" }, { "args": null, "command": "right_delete" } ]

and then overrode the keybinding:

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

Seems to work.

0 Likes