Sublime Text 2: setting file syntax inside the file itself (like Vim modeling)

In VIM, you can force a file type by writing a model like this

# vim:syntax=html filetype=html 

I wanted to get the same for Sublime Text. For example, I liked Sublime Text 2 for using MarkDown syntax for some file with the extension .txt.

+7
source share
3 answers

There is a Modelines plugin for Sublime Text: https://github.com/SublimeText/Modelines

+5
source

To do this for each file with a specific extension, with an open file, go to the View , Syntax , Open all with current extension as... menu and specify your preferences there.

It doesn't seem possible to install it on a file or project, but maybe you should take a look at this package: https://github.com/phillipkoebbe/DetectSyntax

+4
source

Another package management tool available for ST2 / 3 is https://github.com/kvs/STEmacsModelines

using it is very simple, from the docs:

Somewhere in the first five lines of the file, add a line corresponding to the following:

 -*- key: value; key2: value2 -*- 

or

 -*- syntax -*- 
+1
source

All Articles