sublime_alignment icon indicating copy to clipboard operation
sublime_alignment copied to clipboard

Patch to sublime_alignment to allow user to configure how key, separator, varspace, and value are positioned

Open vanrijn opened this issue 13 years ago • 18 comments

This change satisfies my need that I requested at https://github.com/wbond/sublime_alignment/issues/37 and also adds the functionality that was requested at https://github.com/wbond/sublime_alignment/issues/27

Namely, it adds a new config option called alignment_format to allow for the following possible alignment configurations:

   //   background-color: black;
   //   color:            white;
   // "alignment_format": "key-separator-varspace-value"

   // ... or ...
   //   background-color: black;
   //              color: white;
   // "alignment_format": "varspace-key-separator-value"

   // ... or the default ...
   //   background-color: black;
   //   color           : white;
   "alignment_format": "key-varspace-separator-value"

Thanks!

vanrijn avatar Mar 09 '13 23:03 vanrijn

@wbond: I know you're busy with all the package control stuff for ST3, but have you had a chance to look at this yet?

vanrijn avatar Mar 28 '13 23:03 vanrijn

I really like the idea from https://github.com/wbond/sublime_alignment/issues/27 so I modified my code to allow sublime_alignment to do all 3 of the following:

   // This plugin can align the selected lines in a number of ways.
   //   background-color: black;
   //   color:            white;
   // "alignment_format": "key-separator-varspace-value"

   // ... or ...
   //   background-color: black;
   //              color: white;
   // "alignment_format": "varspace-key-separator-value"

   // ... or the default ...
   //   background-color: black;
   //   color           : white;
   "alignment_format": "key-varspace-separator-value"

vanrijn avatar Apr 12 '13 22:04 vanrijn

Looks good - going to be handy :-)

GaryJones avatar Apr 13 '13 21:04 GaryJones

Please merge this

coderberry avatar Apr 24 '13 14:04 coderberry

I like the change, but...is it hard to make both situations work? I use:

h1 span {
    display:          block;
    font-family:      'weblysleek_uisemilight',sans-serif,Arial;
    font-size:        22px;
    font-weight:      400;
    margin-top:       15px;
}

and for JS:

var test              = 23132
,    longvariable     = 343
,    e                = 3434
;

Unfortunately I cannot use both options at the same time. Is it possible that it will do the key/value alignment based on key-separator-varspace-value and the equals value based on key-varspace-separator-value?

mattiLeBlanc avatar Aug 22 '13 08:08 mattiLeBlanc

Let's get this merged.

ericmagnuson avatar Sep 18 '13 05:09 ericmagnuson

@eric, you mean you can make this work? That would be awesome

mattiLeBlanc avatar Sep 18 '13 09:09 mattiLeBlanc

Well, at the time, I was just showing that there was still interest in this pull.

However, since writing that, I forked this repo and pulled in a number of the currently pending pull requests, including this one. It works fairly well I'd say. You should be able to have two different alignment options by editing Javascript.sublime-settings and CSS.sublime-settings, which can be found in the package's folder.

ericmagnuson avatar Sep 18 '13 09:09 ericmagnuson

I have set the the javascript.sublime-settings as: { "alignment_chars": ["=", ":"] } But i notice that if I use = or : alignment in a JS file, it doesn't align as the example of mine above. Maybe i made a configuration error.

But in CSS it is mid aligning the : which I do not want, in JS it is mid-aligning the = which is good, but it is also mid-aligning the : which I would not like

mattiLeBlanc avatar Sep 18 '13 10:09 mattiLeBlanc

Hmm, I couldn't get it to work either. I'll have to see if I can figure out why.

ericmagnuson avatar Sep 18 '13 20:09 ericmagnuson

Glad you had the same result

mattiLeBlanc avatar Sep 20 '13 08:09 mattiLeBlanc

:+1: on getting this into the main project. I hacked together essentially the same solution for my own needs, but would love to see this get in. How can I help?

kerrizor avatar Nov 25 '13 18:11 kerrizor

:+1: Except alignment_format should be for each alignment_char

"alignment_chars": [
  "=": "key-varspace-separator-value",
  ":":  "key-separator-varspace-value"
]

//or

"alignment_chars": [
  {
    "char": "=",
    "format": "key-varspace-separator-value"
  },
  {
    "char": ":",
    "format": "key-separator-varspace-value"
  },
]

James1x0 avatar Sep 04 '14 19:09 James1x0

:+1: I would love to see this being merged in the near future.

fnky avatar Sep 08 '14 09:09 fnky

+1

danillos avatar Apr 23 '15 20:04 danillos

:+1: for merge, please!

ArmorDarks avatar May 28 '15 10:05 ArmorDarks

please make it real :) ! :+1:

btw: how about that?

"alignment_types": {
  "key-varspace-separator-value": ['=', '-', '+', '.'],
  "key-separator-varspace-value": [':']
}

DoubleU23 avatar Mar 10 '16 11:03 DoubleU23

Any news on this?

smartforcedev avatar Sep 14 '16 10:09 smartforcedev