sublime_alignment icon indicating copy to clipboard operation
sublime_alignment copied to clipboard

accounting for initial variable declarations

Open ianstormtaylor opened this issue 14 years ago • 8 comments

Here's what happens:

   var h = thing,
   apple = thing2;

instead of:

var h     = thing,
    apple = thing2;

Would be sweet if it could account for this.

ianstormtaylor avatar Sep 14 '11 22:09 ianstormtaylor

You are right, there is nothing to support this right now. I've got a whole ton going on at work right now, so it is doubtful I would be able to support prefixes in the immediate future.

For more complex alignment, you can use multiple selections fairly effectively. In your case I would select the first equal sign. Then hit ctrl+d (cmd+d on OS X) to select the following equal signs. I would then use ctrl+left to jump to the beginning of the variable before the = signs and then do the alignment.

wbond avatar Sep 16 '11 12:09 wbond

+1, this makes Alignment unusable for most JS developers. :(

mourner avatar Feb 02 '12 10:02 mourner

We have the same problem when we use the comma-first coding-style

var o = {
    first: first
  , second: second
  , third: third
}
// Once
var o = {
    first: first
    , second: second
    , third: third
}
// Twice
var o = {
    first   : first
    , second: second
    , third : third
}

Calvein avatar Jul 16 '12 17:07 Calvein

+1

DarrenN avatar Sep 24 '12 13:09 DarrenN

+1

ludder avatar Oct 16 '12 06:10 ludder

+1

aarontgrogg avatar Aug 15 '13 10:08 aarontgrogg

+1

ziqiming avatar Feb 27 '18 19:02 ziqiming

I made an attempt to fix this issue as well as get some of the other PRs that are outstanding and potentially useful merged in - it's in my master branch fork.

It lets you specify the declaration variables in the settings file - the defaults are the var/let/const words.

Currently you have to run the alignment twice in order to get the "=" aligned correctly as well - I'll try and fix that in a future commit.

sylido avatar Oct 11 '18 01:10 sylido