Patch to sublime_alignment to allow user to configure how key, separator, varspace, and value are positioned
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!
@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?
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"
Looks good - going to be handy :-)
Please merge this
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?
Let's get this merged.
@eric, you mean you can make this work? That would be awesome
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.
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
Hmm, I couldn't get it to work either. I'll have to see if I can figure out why.
Glad you had the same result
:+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?
:+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"
},
]
:+1: I would love to see this being merged in the near future.
+1
:+1: for merge, please!
please make it real :) ! :+1:
btw: how about that?
"alignment_types": {
"key-varspace-separator-value": ['=', '-', '+', '.'],
"key-separator-varspace-value": [':']
}
Any news on this?