Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set SublimeText to auto match brackets but neither quotes or parenthesis?

I find the auto match behavior in sublime text 3 is not quite up to snuff when you're typing code and more importantly when you're going back to edit in real time it can add all kinds of parens or quotes you don't really need.

But it's pretty much always perfect at auto matching squirly brackets {} so that's still a very useful feature especially since I type a lot of them in a local markup language.

I know I can turn auto match off but I don't want to turn off the behavior entirely, just modify it to not auto match "" or ().

Does anyone know the command to put in the user settings for this?

Here's the steps I've done to try to resolve this:

find ~/ -name "Sublime Text"
find ~/ -name "BracketHighlighter"

Both return nothing. So I can't find this 'BracketHighlighter.sublime-settings'

Instead of looking for it on the hard drive, I accessed it via the built in menus in Sublime Text via:

  • Preferences ->
  • Package Settings ->
  • Bracket Highlighter ->
  • Bracket Settings - User

This last menu option opens a file called "~/.config/sublime-text-3/Packages/User/bh_core.sublime-settings. In there I've pasted the code from AGS' answer and toggled:

"auto_match_enabled" : true,
"auto_match_enabled" : false,

I have tried both auto match settings while the code has been saved to the bh_core.sublime-settings file. Neither option produces the result as expected. With auto match on, braces, brackets, and quotes are matched. With auto match off, nothing is matched. But I have confirmed the module is on and active as brackets are getting highlighted when selected.

like image 219
fIwJlxSzApHEZIl Avatar asked Jan 24 '26 01:01

fIwJlxSzApHEZIl


1 Answers

I know I can turn auto match off but I don't want to turn off the behavior entirely, just modify it to not auto match "" or ()

You could install and customize the settings of the BracketHighlighter package.

Disable the system auto-matching:

~/Library/Application Support/Sublime Text 2/Packages/User/Preferences.sublime-settings

"auto_match_enabled": true,

Then edit:

OS X file location:

~/Library/Application Support/Sublime Text 2/Packages/User/BracketHighlighter.sublime-settings

{
            "name": "round",
            "open": "(\\()",
            "close": "(\\))",
            "style": "round",
            "scope_exclude_exceptions": ["string.other.math.block.environment.latex"],
            "scope_exclude": ["string", "comment"],
            "language_filter": "blacklist",
            "language_list": ["Plain text"],
            "find_in_sub_search": "true",
            "ignore_string_escape": true,
            "enabled": true
        },
 {
            "name": "double_quote",
            "open": "(\")",
            "close": "(\")",
            "style": "double_quote",
            "scopes": ["string"],
            "language_filter": "blacklist",
            "language_list": ["Plain text"],
            "sub_bracket_search": "true",
            "enabled": true
        },
like image 192
AGS Avatar answered Jan 26 '26 16:01

AGS