Sublime Forum

Question on Default Syntax recognition per folder (and subs)

#1

Hi,

I’m new to this forum, not so much to sublime (at least in using the standard version).
I am trying to get something to work, to no avail (with different variations).

I would like to set the default syntax recognition to Tcl (not Html Tcl, just standard Tcl), for all files in a certain folder hierarchy. For the background story, I am managing environment-modules files (written in Tcl, but without .tcl extension) and it is getting on my nerves to indicate that the syntax is Tcl every time I open a new file. I wish it knew that in this hierarchy, it will always be Tcl.

I tried the following:
open folder and save project defaults. I tried with the following commands, but it doesn’t work.
(save the file as a .sublime-project file, and open it via Project->Open Project)

{
“folders”:
[
{
“path”: “.” // I also tried with a more explicit hard-coded path
}
],
“settings”:
{
// force Tcl syntax for every file opened in this project
“default_syntax”: “Packages/Tcl/Tcl.sublime-syntax”
}
}

I have also tried using the ApplySyntax Package, and I am stuck as even if the indicatkion in the lower right corner of the sublime text window says ‘Tcl’, the syntax is not recognized unless I explicitly click on it again and specify TCL -> Tcl

I am certainly missing something here, and I have tried to look for information but to no avail. If anyone has any idea on this, I would be very grateful :slight_smile:

0 Likes

#2

I tried also
“default syntax”: “TCL/Tcl”
“default syntax”: “Tcl/Tcl”
No luck.

0 Likes

#3

If the first line of a extension-less file contains # -*- mode: tcl -*-, TCL syntax is applied automatically.

If such emacs mode selector comments are not an option, you could try https://packages.sublimetext.io/packages/ApplySyntax, which can assign syntaxes based on various customizable rules.

0 Likes

#4

Hi @deathaxe,
Thank you very much, this works and doesn’t interfere with the environment-modules requirements which is to have #%Module as the first characters of the first line - I can add your suggestion after that, and presto! It works wonders.
Thanks for the simple and efficient tip.

0 Likes