Sublime Forum

3103 html.erb unable to change default syntax highlighting

#1

In latest build, html.erb files default to HTML syntax highlighting. Selecting “Open all with current extension as” rails -> HTML (rails) does not persist.

0 Likes

#2

I am having the same problem. Is there a fix for this yet?

0 Likes

#3

the same here. Anyone help ?

0 Likes

#4

I have the same problem, I thought it was due to the syntax highlighting, but no matter what I choose, it doesn’t remember the syntax choosed for .erb files. I also have experimented the same issue with scss files.

0 Likes

#5

This is very likely due to using the Material Theme. Until the other day, Material was overriding the syntax association for .html.erb files. Trying to use Open all with current extension as… would fail since it would pick up the extension as just .erb, not .html.erb.

This can be solved by opening the settings file Packages/User/HTML (Rails).sublime-settings and adding html.erb to the extensions setting.

1 Like

#6

Here’s what I have in my HTML (Rails).sublime-settings file.:

{
	"extensions":
	[
		"rails",
		"erb",
		"html.erb"
	]
}

and it’s still not setting the syntax correctly. Did I do this right?

0 Likes

#7

Check what syntax is actually set with view.settings().get('syntax') in the console (and report it here).

0 Likes

#8
 view.settings().get('syntax')
'Packages/User/HTML/HTML.sublime-syntax'

It reports the correct syntax if I manually set it to HTML(Rails) first.

0 Likes

#9

What files do you have in your Packages/User/HTML folder?

0 Likes

#10

Just that syntax file and snippet file that I never use.

0 Likes

#11

I’ve also been having this problem for ages and it drives me crazy whenever I’m working on a Rails project.

view.settings().get('syntax') reports 'Packages/HTML/HTML.sublime-syntax' and I don’t have a Packages/User/HTML folder.

Would love a fix for this.

0 Likes

#12

Execute sublime.find_resources("HTML.sublime-settings") and post the results.

2 Likes

#13
>>> sublime.find_resources("HTML.sublime-settings")
['Packages/One Dark Material - Theme/prefs/Ext/HTML.sublime-settings']

Which is a theme I wasn’t using, but rather:

"theme": "Cobalt2.sublime-theme",
"color_scheme": "Packages/Theme - Cobalt2/cobalt2.tmTheme",

I removed the One Dark Material package and now it shows:

>>> sublime.find_resources("HTML.sublime-settings")
[]

…and voila! Now working as expected. Opening an html.erb file sets the syntax to HTML (Rails).

Thanks for the help!

1 Like

#14

This is what worked for me http://joelstransky.com/how-to-fix-a-multiple-extension-syntax-conflict-in-sublime-text-3/

0 Likes