Better vertical alignment with/without selection in any language for any characters or words.
Place your cursor at where you want your code to be aligned, and use shortcut alt + A
or invoke the Align
command via Command Palette.
betterAlign.surroundSpace
Default value:
betterAlign.surroundSpace : {
"colon" : [0, 1], // The first number specify how much space to add to the left, can be negative.
// The second number is how much space to the right, can be negative.
"assignment" : [1, 1], // The same as above.
"arrow" : [1, 1], // The same as above.
"comment" : 2 // Special how much space to add between the trailing comment and the code.
// If this value is negative, it means don't align the trailing comment.
}
// Orignal code
var abc = {
hello: 1
,my :2//comment
,friend: 3 // comment
}
// "colon": [0, 1]
// "comment": 2
var abc = {
hello : 1
, my : 2 // comment
, friend: 3 // comment
}
// "colon": [1, 2]
// "comment": 4
var abc = {
hello : 1
, my : 2 // comment
, friend : 3 // comment
}
// "colon": [-1, 3]
// "comment": 2
var abc = {
hello: 1
, my: 2 // comment
, friend: 3 // comment
}
// "colon": [-1, -1]
// "comment": 2
var abc = {
hello:1
, my:2 //comment
, friend:3 // comment
}
// Orignal code
$data = array(
'text' => 'something',
'here is another' => 'sample'
);
// "arrow": [1, 3]
$data = array(
'text' => 'something',
'here is another' => 'sample'
);
If you've found a bug, please file at https://github.com/chouzz/vscode-better-align/issues.
If you'd like to help out, fork the repo and submit pull requests.
This work is licensed under Apache License 2.0
The codebase is based on this repository. Thanks @WarWithinMe.