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

前端 未结 7 2069
鱼传尺愫
鱼传尺愫 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:23

    I know this is old but I thought @talklittle had the right idea, the answer just got verbose. A quicker way is to insert spaces after the = and then remove all spaces after the 10th column like this:

       :1,4 s/^\(.*=\) *\(.*\)$/\1                           \2/
       :1,4 s/^\(.\{10\}\) *\(.*\)$/\1\2/
    

提交回复
热议问题