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

Abacus

by khiltd ST2/ST3

An Alignment Plugin for Sublime Text 2 that actually works `⌘⌥^ ]`

Details

  • 2013.07.23.05.22.38
  • github.​com
  • github.​com
  • 4 years ago
  • 1 hour ago
  • 6 years ago

Installs

  • Total 41K
  • Win 22K
  • OS X 16K
  • Linux 4K
Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6
Windows 2 10 13 15 12 11 3 4 5 15 14 10 3 4 7 7 11 22 21 17 4 4 19 7 17 18 14 2 17 19 11 10 10 11 8 8 20 13 4 19 3 4 13 6 12 15
OS X 2 14 2 8 5 7 1 3 4 4 2 10 3 2 0 5 6 8 8 11 2 8 7 8 10 11 3 4 0 10 2 8 9 6 4 7 17 3 7 4 3 5 3 4 3 5
Linux 0 2 1 1 3 1 0 0 2 2 1 4 3 1 1 0 2 1 1 2 2 1 2 2 0 1 1 0 0 1 1 1 1 2 0 1 1 3 2 0 0 0 1 0 0 1

Readme

Source
raw.​githubusercontent.​com

Abacus Alignment Plugin for Sublime Text 2

I'm pretty anal about aligning things in my code, but the alignment plugins I tried were more-or-less one-trick-ponies, and I didn't like any of their tricks, so I made my own.

My one anal pony trick involves allowing you to slide the operator like an abacus bead, toward either the left or the right hand side, by giving each possible token a gravity property like so:

{
    "com.khiltd.abacus.separators": 
    [    
        { 
            "token":                ":",
            "gravity":              "left",
            "preserve_indentation": true
        },
        { 
            "token":                "=",
            "gravity":              "right",
            "preserve_indentation": true
        }
    ]
}

Abacus focuses on aligning assignments in as language-agnostic a manner as possible and strives to address most of the open issues in that other, more popular plugin (it won't even jack up your Backbone routes!). It is, however, an alignment tool and not a full-blown beautifier. It works best when there's one assignment per line; if you like shoving dozens of CSS or JSON declarations on a single line then you are an enemy of readability and this plugin will make every effort to hinder and harm your creature on Earth as far as it is able.

preserve_indentation is a tip that you might be working in a language where whitespace is significant, thereby suggesting that Abacus should make no effort to normalize indentation across lines. It's not foolproof, especially if you set your tab width really, really low, but it tries harder than Cory Doctorow ever has. OK, you're right… It would be impossible for anyone to try harder than that.

Usage

Make a selection, then command + option + control + ].

Think the plugin's crazy? Add the following to your config:

"com.khiltd.abacus.debug": true

and Abacus will dump its thoughts out to Sublime Text's console like so:

margin:0;
          ^
     padding:0;
            ^
    border-style:none;
                ^

Caveats

I've used nothing but Macs since 1984 and do absolutely no testing in Windows or Ububian's window manager of the minute. If something's broken in some OS I don't own, you'll need to have a suggestion as to how it can be fixed as I'm unlikely to have any idea what you're talking about.

I don't care if you like real tabs or Windows line endings and don't bother with handling them. Seriously, what year is this?