Question about Align.vim

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Question about Align.vim

A. S. Budden
Dear all (and especially Dr Campbell),

I've been playing around with aligning some text with the (excellent)
Align.vim.  I've used it a fair amount before, but haven't really
played around with AlignCtrl much until now.  I've managed to use the
"padding" option to _almost_ do what I want, but I was wondering if
there was a way of perfecting this...

(By the way, the following will make no sense at all unless you have a
fixed-width font!)

I have the following in the file:

const uint16 inj_a[] =
{
        320,413,496,563,605,620,605,563,496,413,320,227,
        144,77,35,20,35,77,144,227,320,413,496,563,
        605,620,605,563,496,413,320,227,144,77,35,20,
        35,77,144,227,320,413,496,563,605,620,605,563,
        496,413,320,227,144,77,35,20,35,77,144,227,
        320,413,496,563,605,620,605,563,496,413,320,227,
        144,77,35,20,35,77,144,227,320,413,496,563,
        605,620,605,563,496,413,320,227,144,77,35,20,
        35,77,144,227
};

(there should be 9 lines of numbers above)
and want to realign it to look like:

const uint16 inj_a[] =
{
        320, 413, 496, 563, 605, 620, 605, 563, 496, 413, 320, 227,
        144, 77,  35,  20,  35,  77,  144, 227, 320, 413, 496, 563,
        605, 620, 605, 563, 496, 413, 320, 227, 144, 77,  35,  20,
        35,  77,  144, 227, 320, 413, 496, 563, 605, 620, 605, 563,
        496, 413, 320, 227, 144, 77,  35,  20,  35,  77,  144, 227,
        320, 413, 496, 563, 605, 620, 605, 563, 496, 413, 320, 227,
        144, 77,  35,  20,  35,  77,  144, 227, 320, 413, 496, 563,
        605, 620, 605, 563, 496, 413, 320, 227, 144, 77,  35,  20,
        35,  77,  144, 227
};

I've managed to do this using a two-stage approach at the moment, but
I was wondering if Align could do it all in one.  At the moment what I
do is:

:AlignCtrl p0
:'<,'>Align ,
:'<,'>s/\( *\),/,\1/g

This works absolutely fine and, to be honest, I am happy with the
approach, but I was wondering whether Align could go one step further
and do the whole lot...

Any thoughts?

Many thanks,

Al

P.S. Apologies if the formatting above makes no sense, sadly gmail
doesn't have a fixed width font, thereby making this a tad on the
difficult side -- I'm relying on copy-and-paste without being able to
check properly.