Home Explore Blog CI



neovim

44th chunk of `runtime/doc/options.txt`
629dca16dc0b710c4a99271bfc4cc49e111ec57d586f2ee10000000100000fa0
 expression will be evaluated in the |sandbox| if set from a
	modeline, see |sandbox-option|.
	This option cannot be set in a modeline when 'modelineexpr' is off.

	It is not allowed to change text or jump to another window while
	evaluating 'foldtext' |textlock|.

	When set to an empty string, foldtext is disabled, and the line
	is displayed normally with highlighting and no line wrapping.

						*'formatexpr'* *'fex'*
'formatexpr' 'fex'	string	(default "")
			local to buffer
	Expression which is evaluated to format a range of lines for the |gq|
	operator or automatic formatting (see 'formatoptions').  When this
	option is empty 'formatprg' is used.

	The |v:lnum|  variable holds the first line to be formatted.
	The |v:count| variable holds the number of lines to be formatted.
	The |v:char|  variable holds the character that is going to be
		      inserted if the expression is being evaluated due to
		      automatic formatting.  This can be empty.  Don't insert
		      it yet!

	Example: >vim
		set formatexpr=mylang#Format()
<	This will invoke the mylang#Format() function in the
	autoload/mylang.vim file in 'runtimepath'. |autoload|

	The advantage of using a function call without arguments is that it is
	faster, see |expr-option-function|.

	The expression is also evaluated when 'textwidth' is set and adding
	text beyond that limit.  This happens under the same conditions as
	when internal formatting is used.  Make sure the cursor is kept in the
	same spot relative to the text then!  The |mode()| function will
	return "i" or "R" in this situation.

	When the expression evaluates to non-zero Vim will fall back to using
	the internal format mechanism.

	If the expression starts with s: or |<SID>|, then it is replaced with
	the script ID (|local-function|). Example: >vim
		set formatexpr=s:MyFormatExpr()
		set formatexpr=<SID>SomeFormatExpr()
<	Otherwise, the expression is evaluated in the context of the script
	where the option was set, thus script-local items are available.

	The expression will be evaluated in the |sandbox| when set from a
	modeline, see |sandbox-option|.  That stops the option from working,
	since changing the buffer text is not allowed.
	This option cannot be set in a modeline when 'modelineexpr' is off.
	NOTE: This option is set to "" when 'compatible' is set.

						*'formatlistpat'* *'flp'*
'formatlistpat' 'flp'	string	(default "^\s*\d\+[\]:.)}\t ]\s*")
			local to buffer
	A pattern that is used to recognize a list header.  This is used for
	the "n" flag in 'formatoptions'.
	The pattern must match exactly the text that will be the indent for
	the line below it.  You can use |/\ze| to mark the end of the match
	while still checking more characters.  There must be a character
	following the pattern, when it matches the whole line it is handled
	like there is no match.
	The default recognizes a number, followed by an optional punctuation
	character and white space.

						*'formatoptions'* *'fo'*
'formatoptions' 'fo'	string	(default "tcqj")
			local to buffer
	This is a sequence of letters which describes how automatic
	formatting is to be done.
	See |fo-table| for possible values and |gq| for how to format text.
	Commas can be inserted for readability.
	To avoid problems with flags that are added in the future, use the
	"+=" and "-=" feature of ":set" |add-option-flags|.

						*'formatprg'* *'fp'*
'formatprg' 'fp'	string	(default "")
			global or local to buffer |global-local|
	The name of an external program that will be used to format the lines
	selected with the |gq| operator.  The program must take the input on
	stdin and produce the output on stdout.  The Unix program "fmt" is
	such a program.
	If the 'formatexpr' option is not empty it will be used instead.
	Otherwise, if 'formatprg' option is an empty string, the internal
	format function will be used |C-indenting|.
	Environment variables are expanded |:set_env|.  See |option-backslash|
	about including spaces and backslashes.
	This option cannot

Title: Vim Options: 'formatexpr', 'formatlistpat', 'formatoptions', and 'formatprg'
Summary
This section details several Vim options related to text formatting. It describes the use of 'formatexpr' for defining an expression to format lines, 'formatlistpat' for recognizing list headers, 'formatoptions' for controlling automatic formatting behavior, and 'formatprg' for specifying an external program to format lines.