I recently started using Sublime Text 2. What an awesome editor. It does a great job of highlighting Ruby code, but it does not highlight my Gemfile.
Is there a way to get it to do that?
I found this Gist but it has no instructions on how to use it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are at least three options:
"Gemfile"to the list of Ruby-syntax files1. No explanation, but handy trick
You can bind a keystroke to set syntax without moving to the mouse.
I bound syntax changing to Ctrl-Opt-Space by adding the following to my user keybindings:
2. Add
"Gemfile"to list of Ruby-syntax files~/.config/sublime-text-2/Packages/Ruby/Ruby.tmLanguage~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.tmLanguage%APPDATA%/Sublime Text 2/Packages/Ruby/Ruby.tmLanguageYou can also get there by using the menu option
Preferences -> Browse Packagesand going into the Ruby package. Once you’re in the file it’ll be obvious: it’s the<array>element with Ruby-looking filenames. Add<string>Gemfile</string>and you’re all set.It’s possible the setting could get overwritten on an upgrade; I’m not sure how that works with ST2–it may be cleaner to do it through code as in the snippet.
3. Using the snippet you linked to
More work (and the correction of one syntax error). You can either do it manually, by creating a directory in
Packages(see above for location) or create an actual package and allow ST2 to install it.I created a test package called
"Syntax"and copied the snippet into it, restarted ST2, and opening aGemfileworked as expected. The correction required an additional colon (new gist), nutshell: