51

It's just underlining the matched brackets, Is it possible to make it more useful like changing brackets colour or highlighting the line of brackets?

elboletaire
  • 5,180
  • 2
  • 36
  • 46
Okan Kocyigit
  • 13,203
  • 18
  • 70
  • 129

6 Answers6

70

You can change the color of the brackets modifying your theme's color scheme file.

Go to Preferences / Browse packages open folder Color Scheme - Default find out your current theme file (default's Monokai.tmTheme). Open it using Sublime Text and find the following part:

<key>bracketsForeground</key>
<string>#F8F8F2A5</string>
<key>bracketsOptions</key>
<string>underline</string>

<key>bracketContentsForeground</key>
<string>#F8F8F2A5</string>
<key>bracketContentsOptions</key>
<string>underline</string>

Here you can change the appearance of your brackets. If you change it to something like this:

<key>bracketsForeground</key>
<string>#FF8000</string>
<key>bracketsOptions</key>
<string>foreground</string>

<key>bracketContentsForeground</key>
<string>#FF8000</string>
<key>bracketContentsOptions</key>
<string>foreground</string>

..you'll remove the underline and add an orange color to your brackets.

Take a look to the rest of the file because (maybe) you'll find something more to change ;)

There's no need to restart sublime to see the changes. Just save the file.

Update for Sublime Text3

  1. Go to your Sublime Text 3 installation folder; cd into "Packages" folder. Search for Color Scheme - Default.sublime-package and copy-paste it into your Packages folder (under windows is %APPDATA%\Sublime Text 3\Packages).
  2. Decompress the file (with any unzip tool).
  3. Access the new generated folder and modify your theme's file (same steps as in Sublime Text 2).
  4. After applying your changes save the file and you'll see your changes.
  5. If you want, you can compress again the file as zip using .sublime-package extension but if you do so you must move that file to Installed Packages folder.

Update 2

There's a very usefull package for editing plugins named PackageResourceViewer. It allows you to edit packages very easily, doing all the decompress & move stuff for you.

elboletaire
  • 5,180
  • 2
  • 36
  • 46
  • 1
    The background color of the brackets? I don't know if there is an option for this... maybe the plugin can? I don't know.. I've not tested it. – elboletaire Aug 06 '12 at 16:17
  • 1
    Such a file doesn't exist in Sublime Text 3. I'm using Soda (git checkout) and missed the [Bonus Options](https://github.com/buymeasoda/soda-theme/#bonus-options) but now I've downloaded it and the `Monokai Soda.thTheme` doesn't have any string containing `bracket`. – mmoya Feb 09 '13 at 23:49
  • Well.. the question is about Sublime Text 2... Edit: anyway.. have you tried adding the mentioned section?? – elboletaire Feb 13 '13 at 10:21
  • 1
    There was no ```bracket``` string neither in my ```Packages/PHP-Twig/Extras/Themes/Monokai Dark.thTheme``` but adding these missing blocks did it. – svassr Mar 28 '13 at 19:23
  • 2
    Here's the forum thread that discusses meaning of mentioned theme params: http://www.sublimetext.com/forum/viewtopic.php?f=2&t=3007#p14196 – noitseuq Aug 06 '13 at 09:11
  • @svassr where exactly did you add the code? anywhere inside the ? thanks – appostolis Mar 01 '14 at 12:52
  • [@appostolis](http://stackoverflow.com/questions/10372004/how-to-change-style-of-matched-brackets-in-sublime-text-2/11040624#comment33548495_11040624) yes, add it anywhere as a direct child of ``. – elboletaire Mar 01 '14 at 16:02
  • Works nicely, but is it possible to have also boldness added? fontStyle bold added under the color will affect everything, not really sure what tells the color scheme to change the color only on the active brackets – DoTheEvo Mar 09 '14 at 12:30
  • 1
    It didn't work. :'( There were no "brackets" string, so I added the brackets options inside a dict. What is wrong? –  Aug 03 '16 at 22:54
42

there is plugin BracketHighlighter

features:

  • Customizable highlighting of brackets (),[],<>,{}
  • Customizable highlighting of Tags (supports unary tags and supports self closing /> (HTML5 coming))
  • Customizable highlighting of quotes
  • Selectively disable or enable specific matching of tags, brackets, or quotes
  • Selectively whitelist or blacklist matching of specific tags, brackets, or quotes based on language
  • When using on demand shortcut, show line count and char count between match in the status bar
  • Shortcuts for moving cursor to beginning or end of bracketed content (will focus on beginning or end bracket if not currently multi-selecting)
  • Shortcut for selecting all of the bracketed content
  • and others, see the github site.
fengd
  • 7,551
  • 3
  • 41
  • 44
  • Is there simiral plugin to do the same for search result highlights? – Ozkan Mar 21 '14 at 10:09
  • I tried BracketHighlighter, but like most things on MacOS, it sucked. It had a very limited range of how far it would match brackets. – Cyrcle Dec 01 '17 at 00:36
12

Bracket color & other visibility preferences can be modified without the use of a plugin.   Below is a method for implementing such changes natively.

Note: I recently drafted this answer @ the SublimeText Forum.   There is a similar (unaccepted) answer here, but I have included some unmentioned details & visual reference.


EXAMPLE

This is my personal configuration:

Demo1

Demo2


SETTINGS

Below are all of my visibility related settings.

As you can see in the examples: brackets settings dictate the color of bracket pairs if a caret is placed ON a bracket, whereas bracketContents settings dictate the color of bracket pairs if a caret is placed WITHIN a set of brackets.

My bracketContentsOptions is set to underline, but you can change it to foreground if you want it to be highlighted during both instances.

 

@ Preferences.sublime-settings

"always_show_minimap_viewport" : true,
"caret_extra_bottom"           : 3,
"caret_extra_top"              : 3,
"caret_extra_width"            : 1,
"caret_style"                  : "phase",
"draw_minimap_border"          : true,
"fade_fold_buttons"            : false,
"fold_buttons"                 : true,
"highlight_line"               : true,
"highlight_modified_tabs"      : true,
"line_numbers"                 : true,
"match_brackets"               : true,
"match_brackets_angle"         : true,
"match_brackets_braces"        : true,
"match_brackets_content"       : true,
"match_brackets_square"        : true,
"match_selection"              : true,
"match_tags"                   : true,
"overlay_scroll_bars"          : "enabled",

@ YourColorScheme.tmTheme

    <!-- Indent Guides -->

        <key>guide</key>
        <string>#14191F</string>

        <key>stackGuide</key>
        <string>#14191F</string>

        <key>activeGuide</key>
        <string>#2E4589</string>

    <!-- Highlighted Brackets -->

        <key>bracketsForeground</key>
        <string>#D80E64</string>

        <key>bracketsOptions</key>
        <string>foreground</string>

        <key>bracketContentsForeground</key>
        <string>#D80E64</string>

        <key>bracketContentsOptions</key>
        <string>underline</string>

    <!-- Document Selection -->

        <key>caret</key>
        <string>#D80E64</string>

        <key>lineHighlight</key>
        <string>#121522</string>

        <key>selection</key>
        <string>#1D416B</string>

        <key>selectionForeground</key>
        <string>#bbccff</string>

        <key>selectionBorder</key>
        <string>#4D71FF</string>

        <key>inactiveSelection</key>
        <string>#1D416B</string>

        <key>inactiveSelectionForeground</key>
        <string>#bbccff</string>

    <!-- Search Results -->

        <key>findHighlight</key>
        <string>#0BD0AC</string>

        <key>findHighlightForeground</key>
        <string>#000000</string>
Enteleform
  • 3,753
  • 1
  • 15
  • 30
2

With BracketHighlighter package, edit your theme (tmTheme), and add:

    <dict>
        <key>name</key>
        <string>Tag</string>
        <key>scope</key>
        <string>brackethighlighter.default</string>
        <key>settings</key>
        <dict>
            <key>foreground</key>
            <string>#ffff00</string>
        </dict>
    </dict>
elado
  • 8,510
  • 9
  • 51
  • 60
1
<dict>
    <key>name</key>
    <string>Tag</string>
    <key>scope</key>
    <string>meta.tag, declaration.tag</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#0033CC</string>
    </dict>
</dict>

This changes bracket colors in sb3

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
rgfx
  • 330
  • 2
  • 11
  • 6
    But I need to change them ONLY when highlighting them -- that is, exactly the moment they get an underline. – treecoder Sep 06 '13 at 14:32
0

USE Rainbowth package

How to install in Sublime Text ?

  1. GoTo Sublime Text and press ctrl+shift+p search tab will open
  2. Search for Install Package and enter Rainbowth
  3. After installing package GoTO Preferences > BrowsePackages
  4. GoTo User directory and create a new file "Rainbowth.sublime-settings"
  5. Paste the below config into same file: "Rainbowth.sublime-settings"

##########################################################

{
    "languages":
    [
        "c++",
        "c",
        "python",
        "lisp",
        "scheme",
        "clojure",
        "clojurescript",
        "hylang",
        "js",
        "sass",
        "scss"
    ],
    "palettes":
    {
        "default":
        [
            "#0E4A8E",
            "#3F9101",
            "#BCBF01",
            "#BC0BA2",
            "#61AA0D",
            "#3D017A",
            "#D6A60A",
            "#7710A3",
            "#A502CE",
            "#eb5a00"
        ],
        "Dracula":
        [
            "#E8BA36",
            "#54A857",
            "#359FF4",
            "#5060BB",
            "#179387",
            "#A5BE00",
            "#005FA3",
            "#DB7100",
            "#FFC666",
            "#38FF91"
        ],
        "One Dark":
        [
            "#359FF4",
            "#E8BA36",
            "#54A857",
            "#5060BB",
            "#179387",
            "#A5BE00",
            "#005FA3",
            "#DB7100",
            "#FFC666",
            "#38FF91"
        ]
    },
    "disable_inside_comment": true,
    "disable_inside_string": true,
    "custom_signs":
    {
        "enabled": true,
        "prefix": "({[",
        "suffix": ")}]"
    }
}