Sublime Forum

Creating multiple comment types

#1

I’m really struggling with organizing things in sublime. One of the issues I’m finding is with comments. I often have to write a little blurb above to explain how the code below works, but then I might have actual commented out code below as well and it quickly gets confusing. Especially when I comment out an entire function and that function has bits of ‘non-code comments’ sprinkled all over.

Is there like a system where I can have multiple coloured types of comments…one colour for “text Only”…one for “crossed out code” etc…or something to this degree where I can identify different types of comments. The easiest thing I could do offhand is write --NOTE: blah blah blah; and colour the note a specific colour, but even then I’m low on colours in the dracula colour scheme and I don’t know how u add more colours.

I’m using mostly lua right now so the two cmds are:
ctrl+/: – comments out
(highlighted)ctrl+shift+/: --[[ comments out ]]

Lua also supports further nesting ur block comments --[[ [[ ]] ]] to near infinite degree.

There’s alot to this, but I’m mainly looking for ideas how other people have done such systems before…if there’s screenshots of how ppl have setup multi comment types that would help etc. But just being able to setup a second scope colour thats sorta greyed out like the existing comment colour of dracula would be useful.

0 Likes

#2

Personally, I give a different color to block comments and line comments, and then use block comments for “documentation” type comments and line comments for everything else:

Under this system if I happened to have commented out code, it would be the same color as all other line comments. I don’t find that much of a problem though because such things are usually temporary modifications like in the screenshot, so the gutter gives extra clues.

Color scheme rules are as follows (I use the default color for line comments, but change the style).

        /* This is a block comment */
        // This is a line comment
        {
            "name": "Block Comment",
            "scope": "comment.block, comment.block punctuation.definition.comment",
            "font_style": "italic",
            "foreground": "color(var(blue6) blend(var(blue-vibrant) 30%)))"
        },
        {
            "name": "Comment",
            "scope": "comment, punctuation.definition.comment",
            "font_style": "italic",
        },
1 Like