wbond / sublime_alignment

Easy alignment of multiple selections and multi-line selections
http://wbond.net/sublime_packages/alignment
522 stars 110 forks source link

accounting for initial variable declarations #5

Open ianstormtaylor opened 13 years ago

ianstormtaylor commented 13 years ago

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.

wbond commented 13 years ago

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.

mourner commented 12 years ago

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

Calvein commented 12 years ago

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
}
DarrenN commented 12 years ago

+1

ludder commented 12 years ago

+1

aarontgrogg commented 11 years ago

+1

ziqiming commented 6 years ago

+1

sylido commented 6 years ago

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.