Sublime Forum

How to create indentation and commenting rules for syntax

#1

I’ve successfully created a custom syntax definition which does color highlighting of specific keywords. Now I’d like to make specific indentation rules and commenting rules.

For instance, if you hit “cntrl-/” it is supposed to comment that line out. Well in my custom definition it doesn’t. So how do I explain that command should put a “!” at the beginning of the selected line to make it a comment?

Also, there are certain keywords that when I type them I want the cursor to automatically indent on the next line. Similar to how and “if” statement auto indents the next line on a built in programming language syntax. How can I accomplish that?

0 Likes

#2

Since I’m a paying user and aren’t getting a response on this, is there a better way to get help?

0 Likes

#3

Reverse engineer how the syntax packages work. That is the way most have done it here. The other way is to get lucky when the right person sees your thread and has time to answer.

This I can help with. Comment rules are found in Comment.tmPreferences files. So here is an example where I wanted to use the “::” commenting conventions in batch files: github.com/facelessuser/sublime … references.

Take a look at other packages to see more examples. Hope that helps.

0 Likes

#4

Faceless, thanks. I was able to reverse engineer your file to get a comment going the way I wanted. For some reason I was expecting to create a json file and do the whole build system thing. I didn’t realize you can modify XML files and just change a few things. I have no idea what the UUID needs to be set to. I just made up something and it seems to work.

SublimeText support, Please document how I’m really supposed to do this. Thank you.

0 Likes