I have a file Guardfile
in my rails project, but appears just in plain text, so each time is opened it must be assigned the ruby syntax to display it correctly.
I cannot use Open all with current extension as...
because it doesn't have an extension, but I suppose I could assign a specific syntax to a file without an extension because files like Gemfile
, Capfile
or Rakefile
are displaying correctly.
How can I achieve this?
For Sublime 3:
Commmand + Shift + p
: set syntax rubyAdd syntax like following:
{
"extensions": [
"Gemfile",
"Gemfile.lock",
"Podfile",
"Podfile.lock",
"Manifest.lock",
"Fastfile_helper",
"Fastfile",
"Appfile"
]
}
What really bad is that the syntax does not support fuzzy match, regex thing. This means you must list all the files.
Menu: Preferences -> Browser Packages
Then open the file Ruby\Ruby.tmLanguage
Look up for this block:
<array>
<string>rb</string>
<string>rbx</string>
<string>rjs</string>
<string>Rakefile</string>
<string>rake</string>
<string>cgi</string>
<string>fcgi</string>
<string>gemspec</string>
<string>irbrc</string>
<string>capfile</string>
<string>Gemfile</string>
</array>
Add the new entry:
<string>Guardfile</string>
Install facelessuser / ApplySyntax. It has a built in rule for Guardfiles. It is also good for other random files that should be set as a certain syntax. For example, here is one I set up for a random file that should have Bash syntax.
"syntaxes": [
{
"name": "ShellScript/Shell-Unix-Generic",
"rules": [
{"file_name": ".*random$"}
]
}
]
The name value is the path to the tmLanguage file from Packages. ShellScript is the name of the Packages folder that the tmLanguage file is in. Shell-Unix-Generic is the tmLanguage file name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With