Sublime Forum

Highlight code remarks

#1

Hi folks,

Iā€™ve written a plugin which highlights special keywords like TODO, FIXME, WARNING etc. to visually support me at my work. Itā€™s also possible to write a simple todo list with these (Iā€™m actually planning to write some keyboard shortcuts, language file etc. like the todo plugin for TM has).
Please see the file header for additional installation informations.

Grab the code here:
bitbucket.org/theblacklion/subl ā€¦ remarks.py

Hope you find it useful :smile:,
Oktay.

0 Likes

#2

Sweet! Iā€™ve been wanting to get one of these on the go for a while!

It would be good if the highlighting only occurred if there was a colon after the word, since I tend to type comments in capitals, this highlights it regardless.

0 Likes

#3

Yeah - me too :smile:.
Do you know orgmode.org/ ? Iā€™m currently wondering if I should try a shotā€¦

Iā€™m continuously thinking about improving this plugin. It would be nice if you could give me some examples on how you would like it to behave. Iā€™ll try to make it more flexible to support your use case.
As for me I wanted to highlight just those capitalized words. But I could try to provide different regex patterns for starters and make it configurable.

0 Likes

#4

That could be fun! ā€œHeadersā€ at the beginning of a fileā€¦

[quote=ā€œtheblacklionā€]Iā€™m continuously thinking about improving this plugin. It would be nice if you could give me some examples on how you would like it to behave. Iā€™ll try to make it more flexible to support your use case.
As for me I wanted to highlight just those capitalized words. But I could try to provide different regex patterns for starters and make it configurable.[/quote]

Sure;

DONE:
DONE: Blah blah blah because I'm awesome

But then an option not to highlight if there is a colon, so:

DONE

Would not highlight :smile:

0 Likes

#5

Iā€™ve updated the plugin. New are:

  • Several states are now grouped within ā€œqueuesā€.
  • You can switch between states via key binding.
0 Likes

#6

[quote=ā€œjbrooksukā€]Sure;

DONE:
DONE: Blah blah blah because I'm awesome

But then an option not to highlight if there is a colon, so:

DONE

Would not highlight :smile:[/quote]

Hmmā€¦ plz take a look at the new code. Where could we change the regex to match your requirement? On a per ā€œqueueā€ level?

0 Likes

#7

Iā€™m unsure how to install this plugin. I copied the .py file into my User directory (on Windows %AppData%\Sublime Text 2\Packages\User) where it was automatically compiled to an .pyc file. I also added the Shortcuts into my user-shortcut file and edited my color scheme by adding the code you provided in the file. Do I have to do anything else to enable highlighting (e.g. in JavaScript code)?

0 Likes

#8

Check if there is any error message in the Console using Ctrl ā€™ (apostrophe).
Does the plug-in work for languages other than JavaScript?
Try changing the key-bindings to something else temporarily, as perhaps another plug-in is using alt-down/up.

There are commands you can enter into the console to log commands, and/or key-strokes.

sublime.log_input(True) sublime.log_commands(True)

0 Likes

#9

Okay. The key bindings seem to be binded correctly:

key evt: alt+up command: highlight_code_remarks_switch {"direction": -1} key evt: alt+down command: highlight_code_remarks_switch {"direction": 1}
Unfortunately there seems to be an error in the script during startup:

Reloading plugin C:\Users\visionsbox\AppData\Roaming\Sublime Text 2\Packages\User\highlight_code_remarks.py Traceback (most recent call last): File ".\sublime_plugin.py", line 62, in reload_plugin File ".\highlight_code_remarks.py", line 143, in <module> from support.view import DeferedViewListener ImportError: No module named support.view
May I have missed any dependencies apart from the obvious ones (Iā€™m currently using Sublime Text 2 Build 2210)?

Edit:
Is it necessary to define how comments are written in my coding language? In JavaScript you open a single line comment with double slashes (// comment) and a multi line comment with a slash-star (/* comment */).

As you requested, I also tried to add a remark to your Python file to ensure it is no problem only appearing in JavaScript code. Iā€™m not common to Python code, but I think something like

# TODO: I'm just testing should have been highlighted as a code remark. Unfortunately it didnā€™t.

0 Likes

#10

[quote=ā€œEarMasterā€]Okay. The key bindings seem to be binded correctly:

Unfortunately there seems to be an error in the script during startup:

Reloading plugin C:\Users\visionsbox\AppData\Roaming\Sublime Text 2\Packages\User\highlight_code_remarks.py Traceback (most recent call last): File ".\sublime_plugin.py", line 62, in reload_plugin File ".\highlight_code_remarks.py", line 143, in <module> from support.view import DeferedViewListener ImportError: No module named support.view
May I have missed any dependencies apart from the obvious ones (Iā€™m currently using Sublime Text 2 Build 2210)?
[/quote]

This is not an error, you have to copy the ā€œsupportā€ directory from authorā€™s repository into your plugins directory. It worked for me.
This question answered at the authorā€™s bitbucket repo.

0 Likes