Reputation: 8119
Using an vim-tabular I am attempting to format it as follows:
foo = {
"iSortCol_0" => "1",
"sSortDir_0" => "desc",
"iSortingCols" => "1",
"bSortable_0" => "false",
"bSortable_1" => "true",
"bSortable_2" => "false",
"bSortable_3" => "true",
"bSortable_4" => "false",
"bSortable_5" => "true",
"bSortable_6" => "true",
"bSortable_7" => "true",
"bSortable_8" => "true"
}
I have a list of items in a ruby hash formated randomly, eg as follows:
foo = {
"iSortCol_0" => "1",
"sSortDir_0" => "desc",
"iSortingCols" =>"1",
"bSortable_0" => "false",
"bSortable_1" => "true",
"bSortable_2"=> "false",
"bSortable_3" => "true",
"bSortable_4" => "false",
"bSortable_5" => "true",
"bSortable_6" => "true",
"bSortable_7" =>"true",
"bSortable_8" => "true"
}
I can get it close using Tab /=>
but it does not totally produce the desired result:
foo = {
"iSortCol_0" => "1",
"sSortDir_0" => "desc",
"iSortingCols" => "1",
"bSortable_0" => "false",
"bSortable_1" => "true",
"bSortable_2" => "false",
"bSortable_3" => "true",
"bSortable_4" => "false",
"bSortable_5" => "true",
"bSortable_6" => "true",
"bSortable_7" => "true",
"bSortable_8" => "true"
}
How do I specify how I want let side of the aligned symbol formated? I think I need to utilize \zs
or \ze
but I'm having difficulty applying them for this purpose.
Upvotes: 0
Views: 137
Reputation: 45107
You need to specify the alignment for each section:
Tabularize/=>/r1l1l0
r
for right, l
for left, and c
for center. Each is followed by the number of spaces for each section. So you split on =>
meaning there is a section before the =>
, the =>
itself, and the portion of text after the =>
.
As I am not fond of right aligning you may want to indent your code via =i}
then do :Tabularize/=>/
.
Upvotes: 1