Search

Article:

October 3, 2019

Android Devs XML theme for TextMate (2)

Hello everyone. This is my custom theme for XML text files. I’m learning to develop Android applications but I really do not like Android Studio. So I’m using my fav. text editor: TextMate, and the command line tools to build my apps.I liked to have the same theme of the tutorial I was following so I created the following with the same HEX colors from the – old – Android Developers website.Also I’ve set TextMate to open XML files with my custom theme.
This is how it looks like. If you think there are some corrections to be made or if you have made some fixes or adds, let me know.
screenshot with xml code from the android dev website
Original theme from the Android Developers Website (old version)

screenshot of TextMate showing the Android XML theme
Here is the code. It is not perfectly made, but it works. Also you need the official XML Bundle for it to work since the Scopes are taken from there.
{	colorSpaceName = 'sRGB';
	settings = (
		{	settings = {
				foreground = '#000000';
				background = '#F7F7F7';
				caret = '#000000';
				invisibles = '#BFBFBF';
				selection = '#4D97FF54';
				lineHighlight = '#00000012';
			};
		},
		{	name = 'Punctuation';
			scope = 'meta.tag, punctuation.definition.tag';
			settings = {
				fontStyle = '';
				foreground = '#666600';
			};
		},
		{	name = 'Meta';
			scope = 'meta.tag entity.name, meta.tag entity.other.attribute-name.xml';
			settings = { foreground = '#000000'; };
		},
		{	name = 'Comment block';
			scope = 'comment.block';
			settings = {
				fontStyle = 'italic';
				foreground = '#880000';
			};
		},
		{	name = 'String';
			scope = 'string.quoted';
			settings = { foreground = '#008800'; };
		},
		{	name = 'Tag';
			scope = 'meta.tag.xml punctuation.definition.tag, meta.tag.xml entity.name.tag.namespace, meta.tag.xml entity.name.tag.localname';
			settings = {
				fontStyle = '';
				foreground = '#000088';
			};
		},
		{	name = 'Attribute';
			scope = 'entity.other.attribute-name.namespace.xml, entity.other.attribute-name.xml, punctuation.separator.namespace.xml, entity.other.attribute-name.localname.xml';
			settings = { foreground = '#882288'; };
		},
	);
}
You need to create a new theme and then paste this code inside. Call it whatever you like.In order to assign this theme as the default one to all the XML files, you need to add this property to your TextMate properties file. Mine is located at /Users/umberto/Library/Application Support/TextMate/Global.tmProperties.
[ text.xml ]
fontName         = 'Courier New'
fontSize         = 14
theme            = 752F4472-98E4-4186-8809-74C12417D6BA
Remember to past your theme UUID in place of mine. You can copy your theme UUID by doing a right-click on your theme in Edit Bundles... and selecting Copy UUID.