Formatting can also be achieved with with ={motion}. You can read more about it with :help =
={motion}
:help =
# normal mode gg=G
gg
=
G