Sass support for Sublime Text 2? [closed]

拈花ヽ惹草 提交于 2019-12-28 04:51:29

问题


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 that sass 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 and scss 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 :

  1. install sass-textmate-bundle plugin
  2. open some sass file
  3. 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.

  1. Install PackageResourceViewer
  2. Use the palette to do PackageResourceViewer: Open Resource:



  3. Select Rails then Ruby Haml.tmLanguage:

  4. Comment out the offending line:



  5. Save the file ( this is the awesome part, because the PackageResourceViewer automatically saves just the overridden part automatically to the correct place.

  6. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!