Sublime Forum

Highlighting comments to myself


This may not be possible out of the box, but I’d appreciate any pointers.

I’m using ST3 for writing prose (well, I WIILL once I finish having fun tweaking it). I tend to leave notes for myself in the text, like this: <check this fact. don’t forget to do this or that.>. I’d like to write a macro to help set my notes off, visually, from the main text.

The ideal would be for me to hit a key combo–let’s say super+c–and into the text would be inserted a pair of angle bracket, and the cursor would be between them; I would then type my note. BUT, the whole thing would have a different background and foreground color than my usual writing color scheme–heck, maybe even a different font. Then once I’ve written my note and I mouse-click out of that bracketed area, I’m back in the regular text and ready to keep writing.

I have a feeling this might need to be a plug-in, but not sure. Any thoughts?



Sublime doesn’t support the idea of multiple fonts inside of the same file, so that part is not possible, but the rest is and a plugin isn’t required at all (though of course, you might need one eventually once the ideas start flowing for other things you might want to do :smiley:).

You can create a key binding to insert the text you want, and a combination of a custom syntax definition and a tweak to your color scheme can alter the colors of things as well.

As a simple example, here’s something to get you started. Where the User package is mentioned below, you can find that location by using Preferences > Browse Packages... from the menu or the command palette.

First, a simple syntax definition that you can save into your User package as a sublime-syntax file (here I used Prose.sublime-syntax):

%YAML 1.2
# See
  - prose
scope: text.prose
name: My Prose File Type
    - match: '<'
      scope: punctuation.definition.note.begin
      push: note

    - meta_scope: note.text
    - match: '>'
      scope: punctuation.definition.note.end
      pop: true

This simple syntax applies to files with an extension of prose and recognizes that when it sees a < character, that character and everything up to a matching > character is special and should be treated as such.

Once you put the syntax in place, you can open a .prose file or use the command palette to select the Set Syntax: My Prose File Type command to set the syntax for a buffer, and start typing.

In order to actually visually distinguish notes, you need to have a rule in your color scheme to do so (alternately you can use an existing scope for this, but most color schemes tend to not apply different background colors for anything other than errors, which is probably a bit more vibrant than you want).

To so that, you can create a file like this in your User package. The name of the file has to be named for your current color scheme (visible in the preferences). The extension should always be sublime-color-scheme. Here I’ve named the file Monokai.sublime-color-scheme because that’s what the default color scheme in ST3 is:

            "scope": "text.prose note",
            "foreground": "red",
            "background": "darkblue",

Here of course you’d set the colors as appropriate. You can also use font_style to apply bold and/or italic to the note (or, if you’re using the ST4 beta, you can also make it glow or underline as well).

All that’s left is the key that inserts the note, which would look something like the following (here I chose a different key because I’m on Windows and there’s already a system binding on super+c):

    { "keys": ["ctrl+alt+c"], "command": "insert_snippet",
       "args": {
          "contents": "<$0>"
       "context": [
           { "key": "selector", "operator": "equal", "operand": "text.prose" },

This says that when you press the key in a prose file, the text <> should be inserted, and the cursor ($0) should be between them. Then you can type away:

You can find more information about syntaxes, color schemes (and modifying them) and key bindings (and context on them) in the official documentation and in the unofficial documenation (which also covers snippets).

I also have videos on snippets, key bindings, key binding contexts and a whole series of videos on color schemes on my YouTube channel as well.

This just scratches the surface of things you can do as well. If you need any assistance, the forum is a great place to ask, as well as the discord server (there’s a link in the Resources and Bug Tracking pinned thread), where you can usually get a more “live” back and forth experience, which can come in handy at times.



Holy cow, this is awesome! This is just the kind of thing I had in mind. I plan to work through it tomorrow morning–will learn about syntax definitions and follow your lead from there. I believe I can get my head around it over a couple cups of coffee. Thank you so much.

I know what you mean about flowing ideas leading to other things: If I stick with it, I’ll no doubt eventually dip a toe into plug-in creation. I’ve dabbled with beginner Python in the past, so it’s not completely foreign to me, but I’d have a definite learning curve. And all this fun tweaking and setup means I don’t have to settle down to the drudgery of actually writing just yet. :smile:

I will look into that discord channel as well. Sounds like I should probably be on there.

Thank you again for your time and help.

1 Like


All right, my friend, I’m in business. :smiley:

Since I’m using ST pretty much exclusively for writing txt files, I wrote the syntax definition for txt instead of prose (please let me know if you think that was unwise). Also tweaked the tag just a bit, and voila, it’s behaving beautifully:



ps: I also joined the discord channel… will mostly be a lurker for a while, I’m sure.

1 Like