While it is easy enough to set the language for a given (open) file in Sublime Text, I'm wondering if there is any way that I can tell the editor in advance that anything called "Guardfile" should be highlighted like it's Ruby code. Does anyone know how to do this?
Sublime Text 2: How to set up consistent syntax highlighting for Guardfile?
I happened to come across this plugin that will likely help you: github.com/phillipkoebbe/DetectSyntax –
Roobbie
Or, to simplify & address the core issue: brizzled.clapper.org/blog/2012/02/06/… –
Roobbie
The plugins recommended in the comments by Brian both do the job nicely:
Update:
I couldn't get SyntaxFromFileName to match any of my regex for some reason. On the other hand, DetectSyntax comes with syntax highlight for the Guardfile built in.
Update2:
DetectSyntax has been renamed to ApplySyntax
My theory is that
SyntaxFromFileName
doesn't work with a Guardfile
because a Guardfile doesn't have an extension. Anyway, just confirming ApplySyntax
highlights wonderfully with ambiguous files. –
Kobylak Putting the following at the top of said file also works
#!/usr/bin/env ruby
© 2022 - 2024 — McMap. All rights reserved.