Sublime Forum

Why Sublime Text 3 commenting HTML with {##}?

#1

Why Sublime Text 3 commenting HTML with {##}?

ex:
{# html element here #}

0 Likes

#2

This sounds like an addon error… or the incorrect syntax selected… Note - if you edit any files / folders by means of deleting or extracting a package - be sure to BACKUP the folder in question prior to making changes… You won’t need to backup the entire Packages/ folder, only the HTML/ folder…

Making sure the correct syntax is used:

  • Determine which Syntax is used by opening the following menu:
  • Click View > Syntax
  • HTML should be selected - if not, select it but remember which was selected…

If HTML was selected, then an addon may have modified the highlighter or comment configuration file ( by default, HTML uses block-comments for comments as they’re the only ones available which is )

Open up this folder without the quotes:

  • "%AppData%\Sublime Text 3\Packages\HTML"

If the folder doesn’t exist,

  • Install Package Control if not already installed ( An option to install it should be under the top menu bar under Tools, View, Help or one of the others )…
  • Install “Extract Sublime Package” ( The GitHub link should point to github.com/SublimeText/ExtractSublimePackage )
  • open the folder without quotes: “C:\Program Files\Sublime Text 3\Packages”
  • Double Click HTML.sublime-package
    • If asked which program to open the file with - choose Sublime Text…
  • When the file opens in Sublime Text, it’ll ask you if you want to extract the package:
    • Click OK

Now the folder will exist…

Open up this folder without the quotes:

  • "%AppData%\Sublime Text 3\Packages\HTML"

Next, open the file:

  • Comments.tmPreferences

The contents should be:

<?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[<!-- ]]></string>
			</dict>
			<dict>
				<key>name</key>
				<string>TM_COMMENT_END</string>
				<key>value</key>
				<string><![CDATA[ -->]]></string>
			</dict>
		</array>
	</dict>
</dict>
</plist>

The main bits to look at are:

<string><![CDATA[<!-- ]]></string>

and

<string><![CDATA[ -->]]></string>
  • If you extracted the file - these will be correct….
  • If you didn’t extract the file, these are likely what has changed ( If the View > Syntax > HTML wasn’t selected with a checkmark next to it )…
  • Simply copy the code I provided - Alternatively you may:
    • Extract the HTML.sublime-package to revert the file pack to original
    • Delete the %AppData%\Sublime Text 3\Packages\HTML\ folder which will ensure the default HTML.sublime-package files will be used…
      • If you choose to delete the folder - note the Snippets/ folder within it… I’d suggest creating a backup by either zipping the folder or moving the folder to your desktop or somewhere else which is accessible and test the outcome prior to permanently deleting it…

HTML syntax / comments should be automatically used for comments, etc… when the file is opened… So it could be the comment settings file has been altered which is why the other steps have been included…

Let us know how it went.

0 Likes