Set syntax for a specific file name in Sublime Tex

2019-07-10 02:28发布

问题:

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?

回答1:

Take a look at the ApplySyntax plugin.



回答2:

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!