Sublime Forum

2 Syntaxes on same file with SublimeText 3

#1

Hello,

I am a new user of ST3, and despite lots of queries I haven’t find solution for this question.
What is the process to have 2 différents syntaxes on the same file ?
For instance : line 1 to 100 : syntax “Plain Text” and line 101 to 200 : “Swift” …

Thanks in advance for your help.

0 Likes

#2

You cannot have. Unless you use same preprocessor which process your input file with 2 syntaxes and generated 2 separate files.

This is a preprocessor I know of: (it probably does not do what you would like)

0 Likes

#3

OK thanks
i will use the //method (like a comment), but only one color will be available ;-(

0 Likes

#4

depending on your actual use case, your best bet could be to use the Markdown syntax and use GFM code fences like:

~~~
plain text
...
line 99
~~~
~~~swift
lines 101-200
~~~

but ofc you’ll need to tweak the Markdown syntax definition to support Swift code blocks :wink:

2 Likes