问题
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
- Ensure Package Control is installed. Instructions are found here.
- In Sublime Text, press Ctrl+Shift+P (Win, Linux) or Cmd+Shift+P (macOS) to bring up the quick panel and start typing
Package Control: Install Package
. - Select the command and it will show a list of installable plugins.
- Start typing ApplySyntax; when you see it, select it.
Restart to be sure everything is loaded proper. Enjoy!
来源:https://stackoverflow.com/questions/22232312/set-syntax-for-a-specific-file-name-in-sublime-text-2-3