W
W
Web Lizard2016-07-27 18:28:21
Sublime Text
Web Lizard, 2016-07-27 18:28:21

How to make sublime support html syntax in php documents?

Such a problem - if you enable html syntax in a php document, the php highlighting and all php snippets are turned off, and if you put php, then html snippets stop working, which is very inconvenient.
Can this problem be solved somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Dyrkov, 2016-07-27
@Lizard-108

Snippets are written for a specific scope. If you do not specify it, then the snippet will work in any scope. And with highlighting, everything should be fine, I just went in, I don’t have any themes, everything is well highlighted, php and html.
Here is a snippet for example:

<snippet>
  <content><![CDATA[
<script type="text/javascript" src="./js/${1}"></script>
]]></content>
  <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  <tabTrigger>jslink</tabTrigger>
  <!-- Optional: Set a scope to limit where the snippet will trigger -->
  <scope>text.html(.basic)</scope>
</snippet>

It specifies scope for basic html markup. Only in files with the html extension will this snippet work. Here are all the scopes for sublime. Either ctrl + shift + alt + p and in the status bar you will be shown the scope of the file in which we are now.
If you need a snippet for both html and php, then you can safely leave out the scope (it will work everywhere) or specify it with a comma
On the topic... put php syntax, and php and html are highlighted, rather than just html syntax.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question