I was interested in the set formatoptions+=a option, but even if the idea of reformatting comment in my code or even markdown text is seducing, I cannot really use the feature because I cannot write something like:

Some Text

Immediately, Vim will reformat this as follow:

Heading ======= Some Text

What I need to do is insert a blank line between each entry:



Some Text

Which is not very convenient.

Is there another option that makes this a option a bit smarter?


Another example:

 * Heading.
 * A function that does something
 * @param foo Foo

Will be automatically reformatted:

/** Heading. A function that does something @param foo Foo
  • :set fo+=ac works mostly as advertised, just not for Markdown. Commented Sep 2, 2016 at 8:09
  • Well, it does not work with my example (see my edit) :(
    – nowox
    Commented Sep 2, 2016 at 8:23
  • It works as advertised. That is, it autoformats comments, not the code. :) Commented Sep 2, 2016 at 8:32
  • Try :set fo+=w if you don't mind a trailing space to indicate that a paragraph continues.
    – Antony
    Commented Sep 2, 2016 at 8:39
  • 1
    Cool. Answer added for the archive.
    – Antony
    Commented Sep 2, 2016 at 9:06

1 Answer 1


If you have a in 'formatoptions',

:set formatoptions+=w

can help with the automatic formatting. It means that lines ending with trailing space indicate that the paragraph continues on the next line. The trailing space is automatically added when the line is broken while typing, editing, or when formatting with gq.

A line without trailing space indicates that a paragraph ends at that line, so hitting <Enter> will end a paragraph.

Note that this doesn't affect the operation of text objects. Commands such as gqap will format a regular paragraph, but the formatting will respect the paragraph boundaries determined by the rules for w.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.