问题
Is there an existing package for editing Sass in Sublime Text 2?
This seems to be popular: https://github.com/n00ge/sublime-text-haml-sass
However, after installation, it appears that it only provides syntax highlighting for scss
files.
Ideally, I'd like syntax highlighting, indentation and completions for the sass
syntax.
回答1:
I'd recommend you go with this one: https://github.com/nathos/sass-textmate-bundle, if only for the amazing code completion - compatible with SASS/SCSS.
Whenever in doubt about packages, and assuming you use the amazing Sublime Package Control, just use the packages list, type something (the result will be sorted by the number of installs), and usually the most popular one is the best one.
回答2:
The reason it is only working for your scss files is because the Ruby HAML highlighting settings overrides your sass highlighting.
Goto Preferences
> Browse Packages...
Find and open Ruby Haml.tmLanguage
inside the Rails
folder
change the fileTypes from:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>haml</string>
<string>sass</string> <!-- This line is causing the problem -->
</array>
<key>foldingStartMarker</key>
<string>^\s*([-%#\:\.\w\=].*)\s$</string>
<key>foldingStopMarker</key>
<string>^\s*$</string>
...
to:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>haml</string>
</array>
<key>foldingStartMarker</key>
<string>^\s*([-%#\:\.\w\=].*)\s$</string>
<key>foldingStopMarker</key>
<string>^\s*$</string>
...
Now the SASS highlighting package you installed should be working properly.
回答3:
I did a blog post recently about this: How to Add SASS Support to Sublime Text.
Here's a quick summary:
- To get syntax highlighting, install the sass-textmate-bundle plugin, called simply
Sass
in Package Control. You'll find thatsass
files won't be properly highlighted by default, but in the post I detail a two-second fix that doesn't involve hacking up any of Sublime's default plugins. - Install the SASS Build plugin to enable building
sass
andscss
files from Sublime. - Add the SublimeOnSaveBuild plugin, which automatically runs a build whenever you save changes to a file.
Check out the blog post for full details.
回答4:
regarding to this article :
- install sass-textmate-bundle plugin
- open some sass file
- click View | Syntax | Open all with current extension as … | Sass
回答5:
If a package conflict is causing trouble ( like the Haml issue ) and you need to edit / override a package like removing the <string>sass</string>
part from the Ruby HAML
file, then I would highly recommend the Package Resource Viewer (and editor) plugin.
- Install
PackageResourceViewer
- Use the palette to do
PackageResourceViewer: Open Resource
: - Select
Rails
thenRuby Haml.tmLanguage
: - Comment out the offending line:
Save the file ( this is the awesome part, because the
PackageResourceViewer
automatically saves just the overridden part automatically to the correct place.Done.
Now go and tweak all the little settings / defaults in the other packages that have been annoying you.
回答6:
I ran into the problem of https://github.com/n00ge/sublime-text-haml-sass not recognizing Rails default .css.sass
files because of the extra .css
extension. I agree with Maxime above that using https://github.com/seaofclouds/sass-textmate-bundle is a better option and that installing via the package control is ideal http://wbond.net/sublime_packages/package_control. The way to fix the .css.sass extension not being recognized is to edit the Sass package directly. Go to Sublime Text 2 > Preferences > Browse Packages
and edit the Sass\Syntaxes\Sass.tmLanguage
file. Add <string>css.sass</string>
to the <array>
block.
<key>fileTypes</key>
<array>
<string>sass</string>
<string>css.sass</string>
<string>scss</string>
</array>
来源:https://stackoverflow.com/questions/11309185/sass-support-for-sublime-text-2