SethMMorton
SethMMorton

Reputation: 48875

Set syntax for a specific file name in Sublime Text 2/3

I have a program that uses a file called user.cfg to get its user defined configuration settings. The odd thing is that they chose the syntax for this file to be Tcl (it's not odd that it is Tcl, it's odd they chose the .cfg extension instead of .tcl). So, when I open this file in Sublime Text, it doesn't know what syntax highlighting scheme to choose.

What I would like to do is set the syntax highlighting for user.cfg to Tcl, but not all .cfg files to Tcl.

I have seen this question which is very similar to mine, except in that case the special file name had no extension so Sublime Text knew to assign Ruby highlighting to only that one file. Unfortunately, I have an extension so the solution given there will not work for me.

Is there any known way to get Sublime Text base a highlighting scheme on the full filename?

Upvotes: 3

Views: 2345

Answers (2)

rsc05
rsc05

Reputation: 3820

The previous answer is completely true; however, I thought it would be better to have it here all in one place rather than going on another webpage to find the list of procedure to apply it

Sublime text 3

This is found here

  1. Ensure Package Control is installed. Instructions are found here.
  2. In Sublime Text, press CtrlShiftP (Win, Linux) or CmdShiftP (macOS) to bring up the quick panel and start typing Package Control: Install Package.
  3. Select the command and it will show a list of installable plugins.
  4. Start typing ApplySyntax; when you see it, select it.

Restart to be sure everything is loaded proper. Enjoy!

Upvotes: 1

skuroda
skuroda

Reputation: 19754

Take a look at the ApplySyntax plugin.

Upvotes: 7

Related Questions