GNU/Linux xterm-256color bash 26 views

As much as possible let me walk through the more important step

  1. Use ctrl v with G to replaced every column with | so that the delimiter is consistent, as opposed to having random | in the columns
  2. Start the macro with qq. There’s many things to consider when recording a macro, because you’re trying to ensure the same key bindings work for all cases. Perfect practice make perfect. Craft your macro slowly
  3. As a good habit, press 0 to go to front of line. I think I used _
  4. Yank the first column into the register a
    1. w to advance to the first word
    2. vt| to highlight till the end of delimiter
    3. ge to backtrack until the end of word
    4. "ay to yank into a register
    5. The reason for such weird moves is just to handle the case when the column has more than one word
  5. f| to advance to second column
  6. Repeat the steps as before to yank second column into b
  7. 0 to go back to start of line
  8. c2f| to change the first 2 columns.
    1. ctrl r followed by a to insert content of register a (replace the a with b to insert content of register b)
    2. Format the line however u want, then esc when done
  9. j to go down next line
  10. ctrl v , /---<enter> to select the correct number of rows. f| then ; to select the correct number of columns. Press c to change into desired value.
  11. gv followed by esc to end up on the row divider. 0D to clear the line.
  12. j to go to next line (not required but QoL things)
  13. q to stop recording
  14. @q to replay macro, then @@ to replay the previous macro. Keep pressing @@ until desired changes are made