Search code examples
sublimetext3

How to change color of new Diff Markers in Sublime Text 3?


I want to change the Diff Marker colors that appear just to the right of the number column in sublime text 3 editors.

https://www.sublimetext.com/docs/3/incremental_diff.html

I tried going to preference -> Settings but cannot find any property line_diff_added or line_diff_modifies.

How should I update these colors?


Solution

  • The colors for the mini_diff indicators are specified by the color scheme that you're using; the line_diff_added and other items you mention are contained in that file.

    To modify them you can create a customization on whatever color scheme you're currently using by creating a sublime-color-scheme file in your User package that is named after your color scheme, which contains the customized colors.

    To determine your color scheme, check the color_scheme setting in your preferences; you can also determine where your User package is by using Preferences > Browse Packages if you're unsure.

    When you create such a file in your User package, Sublime will load the base file first and then apply your changes on top; hence you can adjust just the parts of the color scheme that you want while retaining all of the defaults.

    As an example, if you use the Monokai color scheme that ships with Sublime, then creating a file named Monokai.sublime-color-scheme in your User package with the following contents:

    {
        "globals":
        {
            "line_diff_added": "var(yellow2)",
            "line_diff_modified": "var(blue)",
            "line_diff_deleted": "var(red)",
            "line_diff_width": "5"
        },
    }
    

    Will create diff markers similar to this:

    Sample of above color scheme

    In this particular example, the colors being referenced are specified as variables in the base Monokai.sublime-color-scheme file; you're free to choose whatever colors you like for this, of course. You can use View Package File from the command palette to peek at the color scheme you're using if you want to see what it's doing on its own.

    Note also that if you happen to be using a legacy color scheme of type tmTheme, the above still applies; if you were using SomeLegacyTheme.tmTheme, then you would create SomeLegacyTheme.sublime-color-scheme in your User package to customize it (note that the extension is different).

    See the docs on Color Schemes (and in particular on customizing them) for more detailed information on this, including how you can specify the colors you want to use.