Sublime Forum

How to do auto syntaxhighligting without file extension?

#1

I try to edit no ext scripting file. but sublime not detect syntax by look file
at first line shebang. ex: #!/usr/bin/ruby

en.wikipedia.org/wiki/Shebang_%28Unix%29

How to auto detecting syntaxhighligting at such a file?

my testcase
dl.dropbox.com/u/4390580/nohightlight
related userecho
sublimetext.userecho.com/topic/8 … -detected/

0 Likes

#2

The SetSyntax plugin does this:

github.com/SublimeText/SetSyntax

0 Likes

#3

I’ve been using this script to control some syntax highlighting:

gist.github.com/1497794

Put it in your Packages/User directory and modify it to suit your needs.

0 Likes

#4

Does not exist anymore. Is there something similar available for ST3 in 2019?

0 Likes

#5

Sublime Text 3’s sublime-syntax file format supports a first_line_match, which is used to detect the syntax of files without extension.

Some of the builtin syntaxes like ShellScript use first_line_match to support setting syntax based on shebang/editorconfig like tags. Maybe more/all should at least support the -*- Syntax -*- tags though.

If this is not enough for some reason, you could try https://packagecontrol.io/packages/ApplySyntax

0 Likes