Home Download Buy Blog Forum Support

How to syntax-highlight non-files?

How to syntax-highlight non-files?

Postby hibbelig on Sun Jan 01, 2012 12:16 am

I wrote a couple of packages that compute some text to insert into a buffer, and to make it look nice I wanted to add some syntax highlighting. Right now, what I've done is to come up with a "syntax" for my buffer that would allow me to create regexes for syntax highlighting. But actually, this is cumbersome. It would be great if the code that inserted the text into the buffer could specify the syntax highlighting to go alone with it.

Why is it cumbersome to come up with regexes? Well, I'm inserting tabular data that should be lined up nicely in columns. So I could use a column separator (the vertical bar, say) and use that to match the various columns. But what if I want to add or remove columns? Then I have to tweak all the regexes.

There must be other people with the same issue. Find in Files comes to mind -- it also computes text to insert into a buffer, then highlights it. What about SublimeLinter? That might just run an external command and interpret the output...

Hm. Is there a way to add markup to the buffer so that the regexes can interpret the markup, but the markup is then hidden so it's not visible to the user?
hibbelig
 
Posts: 77
Joined: Wed Dec 21, 2011 11:24 pm

Return to Plugin Development

Who is online

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