The gq
command takes comments and indentation into account. I normally use V to visually select the lines (with k and j) and then press gq. The textwidth
option is used to format the lines at the appropriate length. See :help gq
for more information.