I recently started learning Ruby on Rails and of course I had to configure Sublime Text to speed up the workflow. I found Matt Brictson’s article extremely helpful but there was still the pain of typing .erb tags. For some reason the <% %> characters just feel difficult to type.
Then I installed Matthew Robertson’s ERB-Sublime-Snippets which are fantastic but for some reason only work when View -> Syntax -> Rails -> HTML (Rails) is the only syntax selected. Normally that’s a simple matter of choosing View -> Syntax -> Open all with current extension as… but something about files with multiple extensions was confusing Sublime Text. Googling suggested that it’s regex doesn’t just assume everything after the first . is the extension.
I’m not exactly a Sublime Text master so it was very confusing and frustrating to have to manually choose that syntax every time I opened a file. But as with most things, the fix is actually pretty simple.
When ever you choose View -> Syntax -> Open all with current extension as… Sublime Text will create a user preference file in Packages/User named as <Name of Syntax>.sublime-settings
- Create two .sublime-settings files by opening an .html.erb file and choose Open all with current extension as… twice. Once with regular HTML and again with Rails -> HTML (Rails)
- Navigate to that folder by choose Preferences -> Browse Packages… and open both of your newly created .sublime-settings files.
- In HTML.sublime-settings remove all the lines referring to rails or erb including html.erb
- In HTML (Rails).sublime-settings remove all lines referring to plain html
It should work immediately but you may have to restart Sublime Text
Hope that helps.