Sublime Forum

Set default syntax via first line

#1

Hi,
any idea, how set in ST3 that for files with #!/usr/bin/speedy at first line should be used Perl syntax? (I don’t use file extensions).

Thanx.

0 Likes

#2

You should be able to create your own package and take advantage of the ability to embed other syntaxes within your own.

This should work for you:

Speedy/speedy.sublime-syntax:

%YAML 1.2
---
name: Speedy
scope: source.speedy
first_line_match: ^\#!.*\b(speedy)\b


contexts:
  main:
    - include: scope:source.perl
0 Likes