Saturday, September 24, 2011

Sublime Text 2: diff syntax highlighting with a light background color scheme

I recently discovered a new text editor, Sublime Text 2, which I quite like. By default it uses a dark-background color scheme, and while it comes with a few light schemes, none of them have proper syntax highlighting for "diff" files. Fortunately it turned out to be easy to fix:
  1. cd into the Packages/Color Scheme - Default directory.
  2. Copy the scheme you like, e.g. cp iPlastic.tmTheme iPlastic-my.tmTheme.
  3. Change the new file as follows.
  4. To change the theme, edit your preferences file to say
    "color_scheme": "Packages/Color Scheme - Default/iPlastic-my.tmTheme",
    To see the effect of your changes, just save the preferences file.

--- iPlastic.tmTheme	2011-07-31 02:14:25.000000000 +0400
+++ iPlastic-my.tmTheme	2011-09-25 01:29:18.000000000 +0400
@@ -6,5 +6,5 @@
 	<string>Jeroen van der Ham</string>
 	<key>name</key>
-	<string>iPlastic</string>
+	<string>iPlastic-my</string>
	<key>settings</key>
 	<array>
@@ -280,4 +280,50 @@
 			</dict>
 		</dict>
+		<dict>
+			<key>name</key>
+			<string>diff.header</string>
+			<key>scope</key>
+			<string>meta.diff.header</string>
+			<key>settings</key>
+			<dict>
+				<key>foreground</key>
+				<string>#ffffff</string>
+				<key>background</key>
+				<string>#77aadd</string>
+			</dict>
+		</dict>
+		<dict>
+			<key>name</key>
+			<string>diff.deleted</string>
+			<key>scope</key>
+			<string>markup.deleted</string>
+			<key>settings</key>
+			<dict>
+				<key>foreground</key>
+				<string>#F92672</string>
+			</dict>
+		</dict>
+		<dict>
+			<key>name</key>
+			<string>diff.inserted</string>
+			<key>scope</key>
+			<string>markup.inserted</string>
+			<key>settings</key>
+			<dict>
+				<key>foreground</key>
+				<string>#11aa11</string>
+			</dict>
+		</dict>
+		<dict>
+			<key>name</key>
+			<string>diff.changed</string>
+			<key>scope</key>
+			<string>markup.changed</string>
+			<key>settings</key>
+			<dict>
+				<key>foreground</key>
+				<string>#ff2222</string>
+			</dict>
+		</dict>
	</array>
 	<key>uuid</key>