Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I set syntax to PHP in Sublime, all thing is good in my PHP code:

code with syntax highlighted

But when I remove <?php tag from my code, the syntax highlighter doesn't work anymore:

code without syntax highlighted

How can I tell sublime to do syntax highlighting on this specific file (my file extension is .code)?

share|improve this question
I second the problem. even I have the same issue. –  vishal Jul 24 '13 at 16:51
I was unable to solve this. I wanted to do it because I was including PHP code using gulp-preprocess, and needed the tags to be excluded. The only solution I found was to add a step in my gulp build process to strip the tags from the file before processing step. Kind of silly, but not having the highlighting was driving me crazy. –  user1167442 Mar 24 at 3:29

2 Answers 2

Put #<?php at the top of the file. PHP will treat it as a comment. Sublime won't. Perfect.

share|improve this answer
I tried this, but it is far from ideal in my situation. I was importing a lot of scripts into PHP with a pre-processer, and while, able to prevent the execution of this code, it left a whole bunch of superfluous #<?php tags floating throughout the built PHP source file. –  user1167442 Mar 24 at 3:27

With your file open, from the View menu, choose Syntax.... Choose one of the options to set the syntax for that file only. Or, choose Open All with Current Extension As... to specify that all .code files should use the PHP syntax.

share|improve this answer
I did it before and the Syntax is set to PHP. The problem is because my file doesn't contains <?php tag, the Sublime Text won't highlight my code. –  user2480690 Jun 28 '13 at 7:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.