the brx in the walls
the brx in the walls

Reputation: 187

Sublime Text 2: Setting file syntax inside the file itself (as Vim modelines)

In VIM one can force a file type by writing a modeline like this

# vim:syntax=html filetype=html

I'ld like to obtain the same thing for Sublime Text. For example I'ld like Sublime Text 2 to use MarkDown syntax for some file I have with .txt extension.

Upvotes: 7

Views: 1753

Answers (3)

vim
vim

Reputation: 875

Another one available in package control for ST2/3 is https://github.com/kvs/STEmacsModelines

using it is very simple, from the docs:

Somewhere within the first five lines of a file, add a line matching the following:

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

or

-*- syntax -*-

Upvotes: 1

chiborg
chiborg

Reputation: 28094

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

Upvotes: 5

dennis
dennis

Reputation: 865

To do this for every file with a specific extension, with a file open go to menu View, Syntax, Open all with current extension as... and set your preference there.

It doesn't seem to be possible natively to set it per file or project, but propably you should take a look at this package: https://github.com/phillipkoebbe/DetectSyntax

Upvotes: 4

Related Questions