Reputation: 12087
I'm trying to align the following text in vim using tabularize:
typedef struct {
int a;
int *pa;
float b;
float *pb;
double c;
double *pc;
} foo_t;
to this:
typedef struct {
int a;
int *pa;
float b;
float *pb;
double c; /* notice there's only one space between 'double' and 'c' */
double *pc;
} foo_t;
I tried using :'<,'>Tab/.*\s
but it leaves two spaces between double
and c
. How can I do this?
Upvotes: 4
Views: 1939
Reputation: 161664
You can use this command:
:'<,'>Tabularize /\S\+;$/l1
/\S\+;$/
pattern: make a;
,*pa;
...*pc;
as column separators.l1
flag: make every column left
alignment and one
space after it. (Not required here, because it's a default behavior)Upvotes: 7