I found myself writing code without paying attention to formatting: let it be written as it is written, Vim will format it later. And the easiest and fastest way to do this is to format the whole file: gg=G``
.
gg
moves cursor to beginning of file. =G
formats the code from the cursor to the end of the file. ``
brings the cursor back.
Top comments (1)
Also,
gq
is similar to=
. Example:gggqG
The behavior of
=
andgq
are customizable viaequalprg
andformatprg
options respectively.See,
:help =
,:help equalprg
,:help gq
,:help formatprg
for more info.