When I copy code from another file, the formatting is messed up, like this:
fun() { for(...) { for(...) { if(...) { } } } }
How can I autoformat this code in vim?
Try the following keystrokes:
gg=G
Explanation: gg goes 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.
gg
=
G
1.4m articles
1.4m replys
5 comments
57.0k users