Sublime Forum

How to define comment syntax for a language

#1

I’m having a difficult time finding a way to change the comment syntax for a Liquid file. Right now with the Liquid plugin installed when I CMD+/ I get a normal html comment like <!-- --> when I’m really expecting a Liquid comment like {% comment %} {% endcomment %} . I’ve been searching for how to define the beginning and end of a comment for a langauge but haven’t been able to find it in the documentation.

Ideally it would be nice to have single line and multiline selections formatted differently. If it’s possible to completely override the default HTML comments then I would do that since I only program in Liquid and never .html.

0 Likes

#2
0 Likes

#3

https://docs.sublimetext.io/reference/comments.html#shellvariables-subelements

0 Likes

#4

from what I understand tmPreferences files are no longer used and that information is obsolete

0 Likes

#5

Ok, I was able to copy the Comments.tmPreferences file from the HTML language and edit it with these settings and it worked.

<?xml version="1.0" encoding="UTF-8"?>
    <plist version="1.0">
    <dict>
    	<key>name</key>
    	<string>Comments</string>
    	<key>scope</key>
    	<string>text.html</string>
    	<key>settings</key>
    	<dict>
    		<key>shellVariables</key>
    		<array>
    			<dict>
    				<key>name</key>
    				<string>TM_COMMENT_START</string>
    				<key>value</key>
    				<string><![CDATA[{% comment %} ]]></string>
    			</dict>
    			<dict>
    				<key>name</key>
    				<string>TM_COMMENT_END</string>
    				<key>value</key>
    				<string><![CDATA[ {% endcomment %}]]></string>
    			</dict>
    		</array>
    	</dict>
    </dict>
    </plist>
0 Likes

#6

it would be nice to hear where you heard that because it’s untrue :slight_smile:

1 Like

#7

I read somewhere that all of the TextMate tm files in Sublime 4 had been replaced with newer structures like sublime-package and sublime-settings and json files. They may have been talking specifically about color schemes and themes.

0 Likes

#8

No new formats have been added in ST4.

0 Likes