1

I'm using a Compass sprite @import statement in my Sass stylesheet which includes all of the PNG files in a directory (@import 'place-detail-icons/*.png';). Problem is that Macvim sees everything after the /* as a CSS comment, and so it displays the rest of the stylesheet as a comment.

I was able to fix this by putting /**/ on the line below the @import statement in order to fake out Macvim. But was wondering if anyone's found a non-hack way to address this. Here's a larger selection of the code.

@import 'mixins/tabs';
@import 'mixins/timestamps';
@import 'mixins/triangles';
@import 'place-detail-icons/*.png';

  #modal .file-upload {
    margin-bottom: 20px;
  }

  #details {
    position: relative;
    left: -160px;
    width: 1280px;
    min-height: 410px;
    padding: 30px 0 50px;
    border-top: 1px solid $white;
  }

2 Answers 2

2

This is a problem with the CSS syntax file. If you look in :e $VIMRUNTIME/syntax/css.vim on line 179 you'll see this:

syn region cssInclude start="@import" end=";" contains=cssComment,cssURL,cssUnicodeEscape,cssMediaType

If you remove the cssComment from the contains= it will fix it; however, editing the built-in syntax files directly is not advised because your changes will be overwritten when you upgrade vim. Instead, open the file and :sav! ~/.vim/syntax/css.vim to create a duplicate that will override the built-in syntax first and edit that.

Sign up to request clarification or add additional context in comments.

3 Comments

Doesn't seem to be working. I created the new file and edited w/ no effect, then tried editing the original with no luck, syntax is still wrong in MacVim and Vim.
You need to save the file and then set ft=css again or reopen the CSS file. It's working for me.
And in order to make this solution work for Sass files, go through the same process above except open $VIMRUNTIME/syntax/sass.vim, then save and edit ~/.vim/syntax/sass.vim on or around line 56. Thanks Connor.
1

Or you can put this into your ~/.vimrc file: au BufRead,BufNewFile *.scss setfiletype sass
Vim will use the Sass syntax with *.scss files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.