How to Turn Off Autocomplete For Brackets and Quotes in Sublime?

SHARE

Multiple programming and markup languages support, a lot of unique features, powerful shortcuts and highly adjustable user-preferred settings are things that make Sublime one of the most popular code editors nowdays. In an era of open-source software, this is pretty impressive for a proprietary, Python-developed application. 

Still, being too “smart” and “easy to use” is not always a good thing for this kind of software. 

 

With all those handy auto-complete features and suggestions, Sublime can sometimes be more harmful than helpful while trying to predict user attentions as much as possible.

One of the most annoying “smart” feature, users are complaining about, is auto-closing brackets and quotes (also called “auto-pair“). This part of autocomplete logic may be extremely irritating sometimes, especially if you’re lost while trying to write a complex regex line, already containing dozens of brackets.

There’s also a bug in all versions of Sublime regarding this feature, where program “silently swallows” closing bracket, leaving user unaware of situation. Imagine the amount of anger which occurs when you’re a step away from testing and you hit “close bracket” key to close function or some other inline element, save document and finally run your code, hoping for the best. You’ll end up with a syntax error caused by this idiotic feature, which actually was designed to speed up development…

The rest of this post contains a detail explanation on how to stop Sublime from auto-closing brackets and quotes/double quotes. If you’re already familiar with Sublime JSON configuration, just grab the code below.

 

 

How to disable brackets/quotes autoclosing ?

Luckily, this can be turned off pretty easily by overriding default keymap JSON objects related to brackets and quotes functionality.

1  Go to Preferences and select Key Bindings.

2  Your Sublime window will split on two sides containing two documents. Sublime default settings are listed as JSON array on the left side. These values can be changed by putting override JSON values on the right side.  Below are few versions of override code for different purposes. Choose the one which suits your needs, copy it to the right side of Sublime window and go to file menu and select save.

Note:  Make sure to include parent square brackets as these indicate the beginning and the end of JSON configuration array. Otherwise you may be unable to save configuration and get error message saying: Sublime Text: Error trying to parse file…

 

 

Turn off auto-closing for regular, square and curly brackets(also fix closing bracket swallowing bug):

[

{ “keys”: [“(“], “command”: “insert”, “args”: {“characters”: “(“} },
{ “keys”: [“)”], “command”: “insert”, “args”: {“characters”: “)”} },
{ “keys”: [“[“], “command”: “insert”, “args”: {“characters”: “[“} },
{ “keys”: [“]”], “command”: “insert”, “args”: {“characters”: “]”} },
{ “keys”: [“{“], “command”: “insert”, “args”: {“characters”: “{“} },
{ “keys”: [“}”], “command”: “insert”, “args”: {“characters”: “}”} }

]

 

 

 Turn off auto-closing for regular, square and curly brackets as well as quotes and double quotes (also fix closing bracket swallowing bug):

[

{ “keys”: [“(“], “command”: “insert”, “args”: {“characters”: “(“} },
{ “keys”: [“)”], “command”: “insert”, “args”: {“characters”: “)”} },
{ “keys”: [“[“], “command”: “insert”, “args”: {“characters”: “[“} },
{ “keys”: [“]”], “command”: “insert”, “args”: {“characters”: “]”} },
{ “keys”: [“{“], “command”: “insert”, “args”: {“characters”: “{“} },
{ “keys”: [“}”], “command”: “insert”, “args”: {“characters”: “}”} },
{ “keys”: [“‘”], “command”: “insert”, “args”: {“characters”: “‘”} },
{ “keys”: [“\””], “command”: “insert”, “args”: {“characters”: “\””} }

]

 

 

 Turn off auto-closing only for quotes and double quotes:

[

{ “keys”: [“‘”], “command”: “insert”, “args”: {“characters”: “‘”} },
{ “keys”: [“\””], “command”: “insert”, “args”: {“characters”: “\””} }

]

 

 

 

Preserve auto-wrapping selection in brackets/quotes

While auto-closing brackets and quotes may be considered unnecessary, there’s another feature which you may want to preserve. When particular amount of text is selected, pressing bracket or quote key will wrap selection inside brackets/quotes, which usually comes in handy. If you apply some of previous configurations, this feature will be disabled too. If you want to preserve this feature you’ll have to add additional lines to your JSON configuration.  For example:

 

Turn off auto-closing for all kind of brackets/quotes but preserveauto-wrapping selection in brackets/quotes 
(also fix closing bracket swallowing bug)

[

{ “keys”: [“(“], “command”: “insert”, “args”: {“characters”: “(“} },
{ “keys”: [“)”], “command”: “insert”, “args”: {“characters”: “)”} },
{ “keys”: [“[“], “command”: “insert”, “args”: {“characters”: “[“} },
{ “keys”: [“]”], “command”: “insert”, “args”: {“characters”: “]”} },
{ “keys”: [“{“], “command”: “insert”, “args”: {“characters”: “{“} },
{ “keys”: [“}”], “command”: “insert”, “args”: {“characters”: “}”} },
{ “keys”: [“‘”], “command”: “insert”, “args”: {“characters”: “‘”} },
{ “keys”: [“\””], “command”: “insert”, “args”: {“characters”: “\””} },

 

 

{ “keys”: [“(“], “command”: “insert_snippet”, “args”: {“contents”: “(${0:$SELECTION})”}, “context”:
        [
                { “key”: “setting.auto_match_enabled”, “operator”: “equal”, “operand”: true },
                { “key”: “selection_empty”, “operator”: “equal”, “operand”: false, “match_all”: true }
        ]
},
{ “keys”: [“[“], “command”: “insert_snippet”, “args”: {“contents”: “[${0:$SELECTION}]”}, “context”:
        [
                { “key”: “setting.auto_match_enabled”, “operator”: “equal”, “operand”: true },
                { “key”: “selection_empty”, “operator”: “equal”, “operand”: false, “match_all”: true }
        ]
},
{ “keys”: [“{“], “command”: “insert_snippet”, “args”: {“contents”: “{${0:$SELECTION}}”}, “context”:
        [
                { “key”: “setting.auto_match_enabled”, “operator”: “equal”, “operand”: true },
                { “key”: “selection_empty”, “operator”: “equal”, “operand”: false, “match_all”: true }
        ]
},
{ “keys”: [“‘”], “command”: “insert_snippet”, “args”: {“contents”: “‘${0:$SELECTION}'”}, “context”:
        [
                { “key”: “setting.auto_match_enabled”, “operator”: “equal”, “operand”: true },
                { “key”: “selection_empty”, “operator”: “equal”, “operand”: false, “match_all”: true }
        ]
},
{ “keys”: [“\””], “command”: “insert_snippet”, “args”: {“contents”: “\”${0:$SELECTION}\””}, “context”:
        [
                { “key”: “setting.auto_match_enabled”, “operator”: “equal”, “operand”: true },
                { “key”: “selection_empty”, “operator”: “equal”, “operand”: false, “match_all”: true }
        ]
}

]