Sublime Forum

Get TCL Syntax without .tcl extension

#1

I have a bunch of old tcl scripts that I have to support and they do not have a .tcl extension on them so sublime does not recognize them as tcl script. If I put a .tcl on them then sublime does recognize them as tcl. I can not figure out a way to tell sublime that they are tcl once I’ve already loaded them (and they display as just text) or how to tell sublime that any file that has

#!/usr/bin/tclsh

at the beginning is a tcl script. Anyone know how I can do this? None of these tcl script files have any extension on them and it is a pain to add it every time I have to edit one.

0 Likes

#2

github.com/phillipkoebbe/DetectSyntax

0 Likes

#3

I installed the DetectSyntax package using the package controller. I opened up Preferences/Package Settings/DetectSyntax/Settings - User and added

[code]{
// if an exception occurs when processing a function, should it be reraised so the user gets feedback? This is really
// only useful to those writing functions. The average user just wants the plugin to work, so let’s not reraise the
// exception
“reraise_exceptions”: false,

// If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
// The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
// JavaScript syntax, set new_file_syntax to 'JavaScript'.
"new_file_syntax": false,
"syntaxes": 
	{
		"name": "TCL",
		"rules": 
			{"first_line": "^#!/usr/bin/tclsh"}
		]
	}
]

}[/code]

but it is not working. Any suggestions on what I"m not doing correctly here?

0 Likes

#4

OK i fussed around with this and tried getting specific with the language file. I got it working with

[code]{
// if an exception occurs when processing a function, should it be reraised so the user gets feedback? This is really
// only useful to those writing functions. The average user just wants the plugin to work, so let’s not reraise the
// exception
“reraise_exceptions”: false,

// If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
// The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
// JavaScript syntax, set new_file_syntax to 'JavaScript'.
"new_file_syntax": false,
"syntaxes": 
	{
		"name": "TCL/Tcl",
		"rules": 
			{"first_line": ""^#!/.*tclsh""}
		]
	}
]

}[/code]

Thanks for the DetectSyntax package pointer!

0 Likes