Search code examples
vimalignment

VIM: Aligning columns in VHDL


I have first ('_' means a space):

    _stream      : in std_logic_vector(7 downto 0);
    _valid             : in std_logic;
    _ready             : out std_logic;
    _opcode           : out std_logic_vector(7 downto 0);
    _count             : out std_logic_vector(5 downto 0);
    _last               : out std_logic;

I would like to have:

    stream              : in std_logic_vector(7 downto 0);
    valid               : in std_logic;
    ready               : out std_logic;
    opcode              : out std_logic_vector(7 downto 0);
    count               : out std_logic_vector(5 downto 0);
    last                : out std_logic;

The spaces between the first word and ':' are a mix of tabs and spaces. I want to use tabs.


Solution

  • Align the colon it's easy:

    :'<,'>!column -t -s: -o:
    
    -s .................... separator
    -o .................... output separator
    

    After that, you can and some spaces at the beginning by:

    :%norm! I<Space><Space>
    

    Where "<Space>" is typed literally