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:
- left-align reg/wire in first column
- center-align bit-widths, if present, along ‘:’
- left-align signal names in third column
- = signs in the 4th column
- left-align initial values in 5th column.
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.
With two Tabularize commands it can be done like this
So here you basically use
[number:as the delimiter.