Handmade Hero»Forums»Code
Tim
13 posts
TODO, NOTE, etc. highlighting for sublime text
I really like Casey's TODO and NOTE highlights. Does anyone know of a way to get the same functionality in Sublime Text? I went through sublime text package control but didn't find anything that seemed right.
Gus Waldo
10 posts
TODO, NOTE, etc. highlighting for sublime text
Hi, I struggled a bit with this as well.
First thing I tried was using sublime linter, it kinda works but IMO looks ugly and is a bit limited if you want to add or modify stuff.

So I ended up modding the language file and theme I was using.
I'm using C Improved(you can find it in package control) as the tmLanguage. You'll have to add this to your tmLanguage file:

[color=#008888]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<dict>
	<key>match</key>
	<string>(?i)\b(TODO)\b</string>
	<key>name</key>
	<string>annotation.todo.c</string>
</dict>
<dict>
	<key>match</key>
	<string>(?i)\b(NOTE)\b</string>
	<key>name</key>
	<string>annotation.note.c</string>
</dict>	
<dict>
	<key>match</key>
	<string>(?i)\b(IMPORTANT)\b</string>
	<key>name</key>
	<string>annotation.important.c</string>
</dict>	
[/color]

It matters where you put it.
I put it after this part at around line 1070 in CImproved.tmLanguage.
[color=#008888]
1
2
3
4
<key>lex-continuation</key>
<dict>
	<key>patterns</key>
	<array>
[/color]

So with that we've added a scope for the keywords we're looking to highlight. Next we just have to make it so that our theme actually highlight the keywords by adding this to the tmTheme file:


[color=#008888]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<dict>
	<key>name</key>
	<string>TODO</string>
	<key>scope</key>
	<string>annotation.todo</string>
	<key>settings</key>
	<dict>
		<key>fontStyle</key>
		<string>bold</string>
		<key>foreground</key>
		<string>#C42F0E</string>
	</dict>
</dict>
	<dict>
	<key>name</key>
	<string>NOTE</string>
	<key>scope</key>
	<string>annotation.note</string>
	<key>settings</key>
	<dict>
		<key>fontStyle</key>
		<string>bold</string>
		<key>foreground</key>
		<string>#008900</string>
	</dict>
</dict>
	<dict>
	<key>name</key>
	<string>IMPORTANT</string>
	<key>scope</key>
	<string>annotation.important</string>
	<key>settings</key>
	<dict>
		<key>fontStyle</key>
		<string>bold</string>
		<key>foreground</key>
		<string>#CFC927</string>
	</dict>
</dict>
[/color]

final result:


let me know if there's anything else you want to adjust. I've managed to somewhat mirror caseys editor workflow using sublime.
Andre Bauland
12 posts
TODO, NOTE, etc. highlighting for sublime text
Edited by Andre Bauland on
There is also a plugin for that with the SublimeLinter

https://github.com/SublimeLinter/SublimeLinter-annotations

:)
Gus Waldo
10 posts
TODO, NOTE, etc. highlighting for sublime text
thrahistan
There is also a plugin for that with the SublimeLinter

https://github.com/SublimeLinter/SublimeLinter-annotations

:)

it will only allow you to do stuff like change background color, add underlines or a border, not change the color of the text and make it bold. That's what I mean by sublime linter looking ugly. I used annotations before doing it myself and the ugliness of it annoyed me to no end.
Tim
13 posts
TODO, NOTE, etc. highlighting for sublime text
@Skinpop: you are awesome!
Gus Waldo
10 posts
TODO, NOTE, etc. highlighting for sublime text
Glad I could help!
Andre Bauland
12 posts
TODO, NOTE, etc. highlighting for sublime text
Skinpop
thrahistan
There is also a plugin for that with the SublimeLinter

https://github.com/SublimeLinter/SublimeLinter-annotations

:)

it will only allow you to do stuff like change background color, add underlines or a border, not change the color of the text and make it bold. That's what I mean by sublime linter looking ugly. I used annotations before doing it myself and the ugliness of it annoyed me to no end.


yeah, thats true.
I'll gonna use yours now, looks nicer to me :D
Adam
1 posts
TODO, NOTE, etc. highlighting for sublime text
I went searching for this feature as well.

My day to day is in Javascript mostly is there tmLanguage file associated with Javascript in Sublime?

Or would I have to find something along the lines of CImproved but for JS to be able to have these tmLanguage files.

Thanks!
Zenn
19 posts
TODO, NOTE, etc. highlighting for sublime text
I try following the instruction above but can not get it to work.... I'm new to this and only on the first week so I'm not sure were I went wrong.

I am using sublime 3 the only difference I made was to use package viewer to make a copy of the colour scheme and save it in the user folder and use that one instead.

If anyone can help that would be good thank you.
Zenn
19 posts
TODO, NOTE, etc. highlighting for sublime text
Edited by Zenn on
Update....

ok so I got NOTE to be green just like in the example but the other 2 stayed the same color as say the int keyword.... So fiddled around to try to get it and I made things worse note is no longer green and is the same colour as the other two, No matter what I do the colour will not change

Can anyone help? I am wondering if i should just reinstall Sublime?
Zenn
19 posts
TODO, NOTE, etc. highlighting for sublime text
Edited by Zenn on
OK... After about 10 hrs of research plus trial and error I got it!!!!!
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
		<dict>
			<key>name</key>
			<string>TODO</string>
			<key>scope</key>
			<string>storage.type.class.todo</string>
			<key>settings</key>
			<dict>
				<key>fontStyle</key>
				<string>italic</string>
				<key>foreground</key>
				<string>#C42F0E</string>
			</dict>
		</dict>
		<dict>
			<key>name</key>
			<string>NOTE</string>
			<key>scope</key>
			<string>storage.type.class.note</string>
			<key>settings</key>
			<dict>
				<key>fontStyle</key>
				<string>italic</string>
				<key>foreground</key>
				<string>#008900</string>
			</dict>
		</dict>
		<dict>
			<key>name</key>
			<string>IMPORTANT</string>
			<key>scope</key>
			<string>storage.type.class.important</string>
			<key>settings</key>
			<dict>
				<key>fontStyle</key>
				<string>italic</string>
				<key>foreground</key>
				<string>#CFC927</string>
			</dict>
		</dict>


This is in combination with the C improved.
You will have to modify whatever theme you are using and paste it in there.
I did a search for storage.type and pasted the code in after the last </dict>.
1
2
3
4
5
				<key>foreground</key>
				<string>#66D9EF</string>
			</dict>
		</dict>
[paste code here]


Gianluca Alloisio
33 posts
TODO, NOTE, etc. highlighting for sublime text
I used this plugin, I modified a little to include more keywords and to fix a bug. https://bitbucket.org/theGiallo/t...on_sublime_plugins/pull-requests/