Adding column of numbers in linux vi editor

Viewed 82

I have used following commands to add columns in vi editor

visual block (ESC+Ctrl+V) arrows use to select the column x to delete value again ctrl+v Shift+I (go to the top and insert) Type the value Esc+enter

I want to repeatedly add 1 and 2 as in the snapshot attached. Can you please assist me with this. thanks

enter image description here

1 Answers
  • Position the cursor at the location where you want to start typing 1.
  • Start a macro qa.
  • Type what you want to type. i1<esc> jh i2<esc> jh. So that you end up 2 lines below, so that it is something repeatable.
  • Stop the macro q
  • Execute the macro dazilion times 200@a
  • Watch
Related