Platinum Partner
agile,tips and tricks,sublime text

Adding Diff Syntax Highlighting to Sublime Text

My chosen color scheme for Sublime Text doesn't include support for diff/patch files, so I added my own.

To the bottom of my .tmTheme file, I added this just above the closing </array>:

        <dict>
            <key>name</key>
            <string>diff.header</string>
            <key>scope</key>
            <string>meta.diff, meta.diff.header</string>
            <key>settings</key>
            </dict><dict>
                <key>foreground</key>
                <string>#009933</string>
            </dict>
 
        <dict>
            <key>name</key>
            <string>diff.deleted</string>
            <key>scope</key>
            <string>markup.deleted</string>
            <key>settings</key>
            </dict><dict>
                <key>foreground</key>
                <string>#DD5555</string>
            </dict>
 
        <dict>
            <key>name</key>
            <string>diff.inserted</string>
            <key>scope</key>
            <string>markup.inserted</string>
            <key>settings</key>
            </dict><dict>
                <key>foreground</key>
                <string>#3333FF</string>
            </dict>
 
        <dict>
            <key>name</key>
            <string>diff.changed</string>
            <key>scope</key>
            <string>markup.changed</string>
            <key>settings</key>
            </dict><dict>
                <key>foreground</key>
                <string>#E6DB74</string>
            </dict>

This sets up a green colour for the meta information, blue for added lines, red for deleted lines and a yellowish colour for changed.


Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}