vimstatusline

In Vim statusline, right-pad number


Say I do set statusline+=col:%3v; in Vim 8.

Now if I'm on column 1, my statusline looks like col: 1;.

How do I get the padding on the other side of the number? E.g., how do I get my column 1 statusline to look like col:1 ;?


Solution

  • Use %-3v. As documented in :help 'statusline:

    field       meaning  
    -           Left justify the item.  The default is right justified
                when minwid is larger than the length of the item.
    

    This is also the convention used by printf, which vim is clearly imitating.