Have you ever experienced awful code arrangements after pasting the codes to vi or vim editor? Well, you shall worry no more! No matter how messed up was the codes you paste into the editor, you can indent them in a blink with the right command! Let’s see how it works:
- Make sure you are in viewing mode (not insert mode!)
- type the command below directly:
- BOOM! Indented! Happy coding!
(Explanation: “gg” makes the cursor go to the top of the file, “=” is a command to fix the indentation and “G” tells it to perform the operation to the end of the file.)