ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

SCSS Expander

by garetht ALL

Expands the SCSS rule in the current cursor scope.

Details

Installs

  • Total 27K
  • Win 17K
  • Mac 7K
  • Linux 3K
Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10
Windows 0 2 2 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0 2 0 1 0 0 0 1 2 0 0 4 1 1 0 1 0 2
Mac 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0
01234Mar 27Mar 24Mar 21Mar 18Mar 15Mar 12Mar 9Mar 6Mar 3Feb 28Feb 25Feb 22Feb 19Feb 16Feb 13Feb 10Mar 27 Linux: 0 Mac: 0 Windows: 0Mar 26 Linux: 0 Mac: 0 Windows: 2Mar 25 Linux: 0 Mac: 0 Windows: 2Mar 24 Linux: 0 Mac: 2 Windows: 0Mar 23 Linux: 1 Mac: 0 Windows: 0Mar 22 Linux: 0 Mac: 0 Windows: 0Mar 21 Linux: 0 Mac: 0 Windows: 0Mar 20 Linux: 0 Mac: 0 Windows: 0Mar 19 Linux: 0 Mac: 0 Windows: 1Mar 18 Linux: 0 Mac: 0 Windows: 1Mar 17 Linux: 0 Mac: 0 Windows: 0Mar 16 Linux: 0 Mac: 0 Windows: 0Mar 15 Linux: 0 Mac: 0 Windows: 0Mar 14 Linux: 0 Mac: 0 Windows: 1Mar 13 Linux: 0 Mac: 0 Windows: 1Mar 12 Linux: 0 Mac: 0 Windows: 1Mar 11 Linux: 0 Mac: 0 Windows: 0Mar 10 Linux: 0 Mac: 0 Windows: 1Mar 9 Linux: 0 Mac: 0 Windows: 0Mar 8 Linux: 0 Mac: 0 Windows: 1Mar 7 Linux: 0 Mac: 0 Windows: 0Mar 6 Linux: 0 Mac: 1 Windows: 1Mar 5 Linux: 0 Mac: 0 Windows: 0Mar 4 Linux: 0 Mac: 0 Windows: 1Mar 3 Linux: 0 Mac: 0 Windows: 1Mar 2 Linux: 0 Mac: 0 Windows: 0Mar 1 Linux: 0 Mac: 0 Windows: 0Feb 28 Linux: 0 Mac: 0 Windows: 0Feb 27 Linux: 0 Mac: 0 Windows: 0Feb 26 Linux: 0 Mac: 0 Windows: 2Feb 25 Linux: 0 Mac: 0 Windows: 0Feb 24 Linux: 0 Mac: 0 Windows: 1Feb 23 Linux: 0 Mac: 0 Windows: 0Feb 22 Linux: 0 Mac: 0 Windows: 0Feb 21 Linux: 0 Mac: 0 Windows: 0Feb 20 Linux: 0 Mac: 0 Windows: 1Feb 19 Linux: 0 Mac: 1 Windows: 2Feb 18 Linux: 1 Mac: 0 Windows: 0Feb 17 Linux: 0 Mac: 0 Windows: 0Feb 16 Linux: 0 Mac: 0 Windows: 4Feb 15 Linux: 0 Mac: 0 Windows: 1Feb 14 Linux: 0 Mac: 0 Windows: 1Feb 13 Linux: 1 Mac: 0 Windows: 0Feb 12 Linux: 0 Mac: 0 Windows: 1Feb 11 Linux: 0 Mac: 0 Windows: 0Feb 10 Linux: 0 Mac: 0 Windows: 2Mar 27 Linux: 0 Mac: 0 Windows: 0Mar 26 Linux: 0 Mac: 0 Windows: 2Mar 25 Linux: 0 Mac: 0 Windows: 2Mar 24 Linux: 0 Mac: 2 Windows: 0Mar 23 Linux: 1 Mac: 0 Windows: 0Mar 22 Linux: 0 Mac: 0 Windows: 0Mar 21 Linux: 0 Mac: 0 Windows: 0Mar 20 Linux: 0 Mac: 0 Windows: 0Mar 19 Linux: 0 Mac: 0 Windows: 1Mar 18 Linux: 0 Mac: 0 Windows: 1Mar 17 Linux: 0 Mac: 0 Windows: 0Mar 16 Linux: 0 Mac: 0 Windows: 0Mar 15 Linux: 0 Mac: 0 Windows: 0Mar 14 Linux: 0 Mac: 0 Windows: 1Mar 13 Linux: 0 Mac: 0 Windows: 1Mar 12 Linux: 0 Mac: 0 Windows: 1Mar 11 Linux: 0 Mac: 0 Windows: 0Mar 10 Linux: 0 Mac: 0 Windows: 1Mar 9 Linux: 0 Mac: 0 Windows: 0Mar 8 Linux: 0 Mac: 0 Windows: 1Mar 7 Linux: 0 Mac: 0 Windows: 0Mar 6 Linux: 0 Mac: 1 Windows: 1Mar 5 Linux: 0 Mac: 0 Windows: 0Mar 4 Linux: 0 Mac: 0 Windows: 1Mar 3 Linux: 0 Mac: 0 Windows: 1Mar 2 Linux: 0 Mac: 0 Windows: 0Mar 1 Linux: 0 Mac: 0 Windows: 0Feb 28 Linux: 0 Mac: 0 Windows: 0Feb 27 Linux: 0 Mac: 0 Windows: 0Feb 26 Linux: 0 Mac: 0 Windows: 2Feb 25 Linux: 0 Mac: 0 Windows: 0Feb 24 Linux: 0 Mac: 0 Windows: 1Feb 23 Linux: 0 Mac: 0 Windows: 0Feb 22 Linux: 0 Mac: 0 Windows: 0Feb 21 Linux: 0 Mac: 0 Windows: 0Feb 20 Linux: 0 Mac: 0 Windows: 1Feb 19 Linux: 0 Mac: 1 Windows: 2Feb 18 Linux: 1 Mac: 0 Windows: 0Feb 17 Linux: 0 Mac: 0 Windows: 0Feb 16 Linux: 0 Mac: 0 Windows: 4Feb 15 Linux: 0 Mac: 0 Windows: 1Feb 14 Linux: 0 Mac: 0 Windows: 1Feb 13 Linux: 1 Mac: 0 Windows: 0Feb 12 Linux: 0 Mac: 0 Windows: 1Feb 11 Linux: 0 Mac: 0 Windows: 0Feb 10 Linux: 0 Mac: 0 Windows: 2Mar 27 Linux: 0 Mac: 0 Windows: 0Mar 26 Linux: 0 Mac: 0 Windows: 2Mar 25 Linux: 0 Mac: 0 Windows: 2Mar 24 Linux: 0 Mac: 2 Windows: 0Mar 23 Linux: 1 Mac: 0 Windows: 0Mar 22 Linux: 0 Mac: 0 Windows: 0Mar 21 Linux: 0 Mac: 0 Windows: 0Mar 20 Linux: 0 Mac: 0 Windows: 0Mar 19 Linux: 0 Mac: 0 Windows: 1Mar 18 Linux: 0 Mac: 0 Windows: 1Mar 17 Linux: 0 Mac: 0 Windows: 0Mar 16 Linux: 0 Mac: 0 Windows: 0Mar 15 Linux: 0 Mac: 0 Windows: 0Mar 14 Linux: 0 Mac: 0 Windows: 1Mar 13 Linux: 0 Mac: 0 Windows: 1Mar 12 Linux: 0 Mac: 0 Windows: 1Mar 11 Linux: 0 Mac: 0 Windows: 0Mar 10 Linux: 0 Mac: 0 Windows: 1Mar 9 Linux: 0 Mac: 0 Windows: 0Mar 8 Linux: 0 Mac: 0 Windows: 1Mar 7 Linux: 0 Mac: 0 Windows: 0Mar 6 Linux: 0 Mac: 1 Windows: 1Mar 5 Linux: 0 Mac: 0 Windows: 0Mar 4 Linux: 0 Mac: 0 Windows: 1Mar 3 Linux: 0 Mac: 0 Windows: 1Mar 2 Linux: 0 Mac: 0 Windows: 0Mar 1 Linux: 0 Mac: 0 Windows: 0Feb 28 Linux: 0 Mac: 0 Windows: 0Feb 27 Linux: 0 Mac: 0 Windows: 0Feb 26 Linux: 0 Mac: 0 Windows: 2Feb 25 Linux: 0 Mac: 0 Windows: 0Feb 24 Linux: 0 Mac: 0 Windows: 1Feb 23 Linux: 0 Mac: 0 Windows: 0Feb 22 Linux: 0 Mac: 0 Windows: 0Feb 21 Linux: 0 Mac: 0 Windows: 0Feb 20 Linux: 0 Mac: 0 Windows: 1Feb 19 Linux: 0 Mac: 1 Windows: 2Feb 18 Linux: 1 Mac: 0 Windows: 0Feb 17 Linux: 0 Mac: 0 Windows: 0Feb 16 Linux: 0 Mac: 0 Windows: 4Feb 15 Linux: 0 Mac: 0 Windows: 1Feb 14 Linux: 0 Mac: 0 Windows: 1Feb 13 Linux: 1 Mac: 0 Windows: 0Feb 12 Linux: 0 Mac: 0 Windows: 1Feb 11 Linux: 0 Mac: 0 Windows: 0Feb 10 Linux: 0 Mac: 0 Windows: 2

Readme

Source
raw.​githubusercontent.​com

SCSS Expander

Build Status

Suppose you're working on a particularly long project written using the SCSS syntax, and you're starting to forget the nesting structure of the current rule is.

//... {
        .foo {
          &.bar {
            // what CSS rule is being generated here?
          }
        }
//... }

It's possible to look at the generated CSS, of course, if the generated stylesheets are not too complex. But even that requires keeping another file open somewhere and hunting for line numbers. Most of the time you just want an answer straight away; here, you might get this answer:

.bim
.baz
.foo.bar

(because Sublime Text's alert window has remarkably little space.)

Installation and Usage

sublime-scss-expander does that for you. To install, either place this repository in the Sublime packages folder or use the far simpler Sublime Package Control. Press ctrl+shift+p on Windows/Linux and cmd+shift+p on a Mac to bring up Sublime's Command Palette, then type install package to bring up Package Control's package selector. It should be the first selection. Type SCSS Expander which, again, should be the first selection, and then hit enter.

To use, position the cursor in the scope of the rule you want to know about, and press command-E by default to show the rule that is in scope at that position. It is also available in the command palette as SCSS Expander: Expand Cursor Scope.

Support

It supports most sane uses of SCSS, including SASS 3.3's @at-root with all possible arguments, various permutations of the parent selector as well as combinatorically combined comma-separated rules.

Because it is not a parser, it works only when you give it correct code. It does not expand content-blocks that masquerade as rules. It does not even attempt to peek inside any imports.

Examples

Here are a few examples of how it works. In each case assume the cursor is placed in the innermost scope. All examples are drawn from the tests; look in the test file for more.

Comma-separated rules

.first-rule, .second-rule {
  &:hover {
    font-weight: 500;
  }
}
.first-rule:hover,
.second-rule:hover

Interpolated variables

.bim {
  @for $thing in (foo bar) {
    .test-#{$thing}-bling {
      width: 20px;
    }
  }
}
.bim .test-#{$thing}-bling

At-root without

@media screen {
  @supports something {
    .foo {
      @at-root(without: rule media) .bar {
        top: 0;
      }
    }
  }
}
@supports something .bar

Tests

There's a mound of tests which hopefully give good coverage. These are located in scss_expand_test.py. This does not test Sublime Text directly; instead, the expander can and has been generalized to work with any piece of text given a starting position within that text and a function that, given an index, returns the character at that position within the text. This means that the main Python class, SCSSExpander, can be exported for use with other projects.