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

二次信任 提交于 2019-12-14 02:17:54

问题


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!



来源:https://stackoverflow.com/questions/22232312/set-syntax-for-a-specific-file-name-in-sublime-text-2-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!