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

Abacus

by khiltd ST2/ST3 Missing

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

Details

  • 2013.07.23.05.22.38
  • github.​com
  • github.​com
  • 5 years ago
  • 1 year ago
  • 7 years ago

Installs

  • Total 42K
  • Win 22K
  • OS X 16K
  • Linux 4K
Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28
Windows 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 0 0 0 0 0 0 0 0 0 0 0 0 0
OS X 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 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 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 0 0 0 0 0 0 0 0 0 0 0 0 0

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?