Sublime Forum

Determine type of file

#1

Hi,
I am working on a plugin which creates customizable comments based on the type of file.

Eg if the file is a CSS file or JS file it uses the /* …*/ as commenter lines.

Is there a way to determine what kind of file it is as I would like the plugin to check whether its an HTML file or css or js and then add the type of commenting structure.

So if it an HTML file, my output would be something like

<!--//my comment-->

if it is a CSS or JS file, my output would be

/* my comment */

Appreciate your help. I tried searching for something like this but havent had much success.

Thanks,
Gautam

0 Likes

#2

Take a look at the Default/comments.py plugin, which implements the toggle_comment command.

0 Likes

#3

Hi FitchteFoll,
Thanks for your help. Unfortunately i am using Sublime Text 3 and I cant find the comments.py plugin there. Any idea if the folder is moved in Sublime Text 3

0 Likes

#4

No, it’s just inside “Installed Packages/Default.sublime-package”, which is a zip archive. Install PackageResourceViewer and browse the file using that.

0 Likes