Sublime Forum

Switching syntax within one file

#1

Is it possible with Sublilme to get it to recognize different parts of the one file as being different languages that require different syntax formats.

I have HTML files with embedded javascript (within tags) and also C# code within defined tags.

I know that I can switch language on the fly, but it is a bit tedious if your are moving from one to the other and back all of the time.

0 Likes

#2

Yes it is possible. As you’ve pointed out, you can nest JavaScript syntax within HTML files. You need to edit the tmLanguage file. You will define a start and end pattern, and include the relevant scope. You may want to reference here and here. You may also want to investigate how HTML includese JavaScript syntax as a guide.

0 Likes