Code highlighting for custom file extensions


#1

Is there any way we could specify code highlighting aliases for custom file extensions? We’re using an XML-ish format, .iml, which would highlight just fine, but for other reasons we don’t necessarily want to use the .xml extension.


#2

I had the same lack of highlighting editing xhtml files which have an xhtml extension.

Based on Syntax highlighting for jsx in .js files?

I now use this bookmarklet

    javascript:(function() {   application.editor().setOption("mode", "text/xml"); 
                               CodeMirror.autoLoadMode(application.editor(), "xml"); })()

https://codemirror.net/doc/manual.html#config documents how to use setOptions, in particular “mode”. For example one could also provide xml mode option, it seems.