Home Download Buy Blog Forum Support

Automatic Syntax Highlighting?

Automatic Syntax Highlighting?

Postby talsit on Mon Apr 07, 2008 7:56 am

One thing I'd really like to see is the ability for Sublime to automatically detect formats and apply syntax highlighting for files that it doesn't recognize.

Ok, this may get a bit annoying if it constantly does it wrong, so, maybe you can have a menu option: View->Apply Syntax Highlighting->Guess. It could take an educated guess, and apply it. That way, we can bind it to a key, try it, and if it's guessed wrong, then we can manually tell it what to use.

That'd be my personal fav for the week :)
talsit
 
Posts: 6
Joined: Fri Apr 04, 2008 2:44 pm

Re: Automatic Syntax Highlighting?

Postby talsit on Mon Apr 07, 2008 8:00 am

Another thing, not quite related, but sorta, is extensionless files. For example, Makefiles, or SConstruct. They exist, they have a format and syntax, and should be highlighted, but, as far as I can tell, there's no way to specify that sublime should match the entire file's name, not just the (non-existant) extension...
talsit
 
Posts: 6
Joined: Fri Apr 04, 2008 2:44 pm

Re: Automatic Syntax Highlighting?

Postby jps on Mon Apr 07, 2008 3:02 pm

This is something the .tmLanguage format has some support for (via a regex that matches against the first line of the file). Supporting this isn't entirely trivial due to Sublime Text's asynch file loading, but is definitely on the todo list.

Support for SConstruct etc files is also on the todo list, though as a short term work around you can set the syntax to use automatically via a plugin. It's not pretty, but it'll get the job done. Something along the (untested) lines of:

Code: Select all
SConstructSyntaxPlugin(sublimeplugin.plugin):
    def onLoad(self, view):
        if os.path.basename(view.fileName()) == 'SConstruct':
            view.options.set('syntax', 'Packages/Python/Python.tmLanguage')
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: Automatic Syntax Highlighting?

Postby gpfsmurf on Mon Jun 23, 2008 7:29 pm

About choosing file syntax...

It would be nice if the list of file types in the status bar button could be customized. Either with a MRU-like list, or a user filtered selection (like in notepad++)

The idea is to have the full selection of file types in the menu bar, and a smaller selection in the status bar for frequently used types.

By the way, is there a way to properly syntax highlight XML files with embedded scripts? I often have to work with XML that have embedded JavaScript, Perl or Python in CDATA sections.
Basically my question is: if I make my own XML.tmLanguage file, can I specify that if an XML node matches a certain regex pattern, then its CDATA content should be highlighted using another .tmLanguage file? (i.e. some kind of link/include)

Thanks!
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Google [Bot] and 6 guests