Reputation: 1826
I'm using the Tabularize plugin in Vim and have the following text:
reg [321:123] ip_addr=32'h12345678;
reg [15:0] trie_data=16'h9abc;
reg [2:0] select=3'h5;
wire [3:0] nibble;
wire sram_bit;
which I want to align in this manner:
reg [321:123] ip_addr = 32'h12345678;
reg [15:0] trie_data = 16'h9abc;
reg [2:0] select = 3'h5;
wire [3:0] nibble;
wire sram_bit;
In words:
So far, I've tried the following in order:
:Tabularize /[[0-9]*:/l1r0l0
:Tabularize /:[0-9]*]/l0l1l0
:Tabularize /=
but this combines 'wire' and 'sram_bit' in the first column instead of putting it in the first and third column respectively.
Upvotes: 3
Views: 1959
Reputation: 393969
Or with Align.vim
:AlignCtrl <>
:AlignCtrl p0
:%Align \S\+
:AlignCtrl p1
:%Align =
I have the feeling that there should be a simple way to combine those, but I didn't quite figure it out at once, so I'll leave it for another day
Upvotes: 1
Reputation: 3694
With two Tabularize commands it can be done like this
:Tabularize /[[0-9]*:/l1c0l0
:Tabularize /=
So here you basically use [number:
as the delimiter.
Upvotes: 2