How to insert spaces up to column X to line up things in columns?

前端 未结 7 2041
鱼传尺愫
鱼传尺愫 2020-12-04 09:45

I have my source code for copy operators written as follows.

foo = rhs.foo;
foobar = rhs.foobar;
bar = rhs.bar;
toto = rhs.toto;

I\'d like

相关标签:
7条回答
  • 2020-12-04 10:31

    An alternative solution is to perform two consecutive substitutions:

    %s/=/     =/
    %s/\%>7c *//
    

    The trick is the column pattern \%>7c that matches white spaces * only after the 7th column. Here foobar is the longest variable name with 6 characters so we need 7 in the regex.

    0 讨论(0)
提交回复
热议问题