1

I got something like this in vim:

awqwq:bsak
cslqw:aslkjqwd
ska:jsqpwiq
salsqwqw:wpqwi

How to change it quickly to this:

awqwq              :   bsak
cslqw              :   aslkjqwd
ska                :   jsqpwiq
salsqwqw           :   wpqwi
romainl
  • 186,200
  • 21
  • 280
  • 313
alex_cj96
  • 39
  • 1
  • 4

1 Answers1

3

Save the following macro:

f:40i ^[l4a ^[20|dt:j0
to register a. Then place the cursor at the beginning of the text and repeat the macro with 4@a. In this macro ^[ is the escape character which can be obtained from insert mode by typing <ctrl-v><esc>.
builder-7000
  • 7,131
  • 3
  • 19
  • 43
  • I don't understand `^[14a` and `j0` ....could you explain this, thanks~ – alex_cj96 Jan 29 '18 at 10:27
  • 2
    @leavesdrift the macro means `f:` find the : in the line (go there), `40i ` insert 40 spaces before :, `^[` press , `14a ` insert 14 spaces after :, `^[` press , `20|` go to the 20th column `dt:` remove the spaces from 21 to the : char, `j` go to the next line, `0` place the cursor on the first char. If you go to the first line you have to format and press `qa` you will start record a macro on key a that will last until you exit the file. Just type the keysequence @Sergio gave you and then press q to save it. invoke it with _n_@a to apply it to the next _n_lines from the cursor – Eineki Jan 29 '18 at 12:32