Force Syntax Highlight for Files? Feature Request

In Sublime Text I can override the extension of a file and make the syntax highlight in any syntax it knows.  

I would like this to be possible in JetBrains IDEs

IF:

  • a file has no extension or
  • a file has multiple syntaxes in it
  • (neither are necessarily good practices)


I really need to be able to specify the "syntax highlighting", of the file regardless of its "file type".

This doesn't seem to be possible in PHPStorm and I'm guessing others neither.

Is this possible?  If not, consider this a feature request.

Thanks!

James Saxon
3 comments

Hello!

not sure I've got what you are trying to accomplish... Some examples would be helpful.

for files with multiple syntaxes you can use language injections (http://www.jetbrains.com/webstorm/webhelp/using-language-injections.html). In some cases the languages are injected automatically (like javascript in <script type="text/javascript"> tags, for other you can use custom injections. If you just like to 'override' default highlighting for the certain file (for example, treat 'myFile.php' as HTML), you can add 'myFile.php' to HTML registered patterns in Settings/File types/HTML

See also: http://stackoverflow.com/questions/12781037/highlighting-js-code-inside-php-file/12781375#12781375 and http://stackoverflow.com/questions/18101130/phpstorm-syntax-highlighting-for-php-code-inside-xml-tags

0

Thanks!

This helped to understand that the solution comes from "IntelliLang" via "Language Injections".

While there's no way to simply force a syntax, IntelliLang does a beautiful job.  

With Injections, one can specify another language inline if necessary.

In my case, the issue boiled down to not having a Bash colorizer which I found in third party plugins.

Once I installed that, it was handling files without extensions fine!

Thanks again for the pointers!

James

0

The answer is that IntelliLanga appears to correctly sense languages in all files if it knows the language. If not, there's probably a plugin needed. In this case a bash one. So even without file extensions, languages are sensed correctly.

0

Please sign in to leave a comment.