Sublime Text 2: How to set up consistent syntax highlighting for Guardfile?
Asked Answered
A

2

6

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?

Almedaalmeeta answered 6/8, 2012 at 3:1 Comment(2)
I happened to come across this plugin that will likely help you: github.com/phillipkoebbe/DetectSyntaxRoobbie
Or, to simplify & address the core issue: brizzled.clapper.org/blog/2012/02/06/…Roobbie
A
9

The plugins recommended in the comments by Brian both do the job nicely:

  1. ApplySyntax
  2. SyntaxFromFileName

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

Almedaalmeeta answered 6/8, 2012 at 3:32 Comment(1)
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
C
7

Putting the following at the top of said file also works

#!/usr/bin/env ruby
Contrived answered 8/4, 2013 at 23:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.