context based indenting of comments but cannot replicate many three piece
indent alignments. However, 'indentexpr' has the ability to work better with
three piece comments.
Other examples: >
"b:*" Includes lines starting with "*", but not if the "*" is
followed by a non-blank. This avoids a pointer dereference
like "*str" to be recognized as a comment.
"n:>" Includes a line starting with ">", ">>", ">>>", etc.
"fb:-" Format a list that starts with "- ".
By default, "b:#" is included. This means that a line that starts with
"#include" is not recognized as a comment line. But a line that starts with
"# define" is recognized. This is a compromise.
*fo-table*
You can use the 'formatoptions' option to influence how Vim formats text.
'formatoptions' is a string that can contain any of the letters below. You
can separate the option letters with commas for readability.
letter meaning when present in 'formatoptions' ~
*fo-t*
t Auto-wrap text using 'textwidth'
*fo-c*
c Auto-wrap comments using 'textwidth', inserting the current comment
leader automatically.
*fo-r*
r Automatically insert the current comment leader after hitting
<Enter> in Insert mode.
*fo-o*
o Automatically insert the current comment leader after hitting 'o' or
'O' in Normal mode. In case comment is unwanted in a specific place
use CTRL-U to quickly delete it. |i_CTRL-U|
*fo-/*
/ When 'o' is included: do not insert the comment leader for a //
comment after a statement, only when // is at the start of the line.
*fo-q*
q Allow formatting of comments with "gq".
Note that formatting will not change blank lines or lines containing
only the comment leader. A new paragraph starts after such a line,
or when the comment leader changes.
*fo-w*
w Trailing white space indicates a paragraph continues in the next line.
A line that ends in a non-white character ends a paragraph.
*fo-a*
a Automatic formatting of paragraphs. Every time text is inserted or
deleted the paragraph will be reformatted. See |auto-format|.
When the 'c' flag is present this only happens for recognized
comments.
*fo-n*
n When formatting text, recognize numbered lists. This actually uses
the 'formatlistpat' option, thus any kind of list can be used. The
indent of the text after the number is used for the next line. The
default is to find a number, optionally followed by '.', ':', ')',
']' or '}'. Note that 'autoindent' must be set too. Doesn't work
well together with "2".
Example: >
1. the first item
wraps
2. the second item
< *fo-2*
2 When formatting text, use the indent of the second line of a paragraph
for the rest of the paragraph, instead of the indent of the first
line. This supports paragraphs in which the first line has a
different indent than the rest. Note that 'autoindent' must be set
too. Example: >
first line of a paragraph
second line of the same paragraph
third line.
< This also works inside comments, ignoring the comment leader.
*fo-v*
v Vi-compatible auto-wrapping in insert mode: Only break a line at a
blank that you have entered during the current insert command. (Note:
this is not 100% Vi compatible. Vi has some "unexpected features" or
bugs in this area. It uses the screen column instead of the line
column.)
*fo-b*
b Like 'v', but only auto-wrap if you enter a blank at or before
the wrap margin. If the line was longer than 'textwidth' when you
started the insert, or you do not enter a blank in the insert before
reaching 'textwidth', Vim does not perform auto-wrapping.
*fo-l*
l Long lines are not broken in insert mode: When a line was longer than
'textwidth' when the insert command started, Vim does not
automatically format it.
*fo-m*
m Also break at a multibyte character above 255. This is useful for
Asian text where every character is a word on its own.
*fo-M*
M When joining lines, don't insert