Home Explore Blog CI



neovim

6th chunk of `runtime/doc/options.txt`
ae4cb1604821aeb2262956d56270b71cb848360faeec389c0000000100000fa8
 want to use
another 'makeprg' for it, without changing the value used for the C source
files.  You use this command: >
	:setlocal makeprg=perlmake
You can switch back to using the global value by making the local value empty: >
	:setlocal makeprg=
This only works for a string option.  For a number or boolean option you need
to use the "<" flag, like this: >
	:setlocal autoread<
Note that for non-boolean and non-number options using "<" copies the global
value to the local value, it doesn't switch back to using the global value
(that matters when the global value changes later).  You can also use: >
	:set path<
This will make the local value of 'path' empty, so that the global value is
used.  Thus it does the same as: >
	:setlocal path=
Note: In the future more global options can be made |global-local|.  Using
":setlocal" on a global option might work differently then.

						*option-value-function*
Some options ('completefunc', 'findfunc', 'omnifunc', 'operatorfunc',
'quickfixtextfunc', 'tagfunc' and 'thesaurusfunc') are set to a function name
or a function reference or a lambda function.  When using a lambda it will be
converted to the name, e.g. "<lambda>123".
Examples:
>
	set opfunc=MyOpFunc
	set opfunc=function('MyOpFunc')
	set opfunc=funcref('MyOpFunc')
	set opfunc={a\ ->\ MyOpFunc(a)}

Set to a script-local function: >
	set opfunc=s:MyLocalFunc
	set opfunc=<SID>MyLocalFunc

Set using a funcref variable: >
	let Fn = function('MyTagFunc')
	let &tagfunc = Fn

Set using a lambda expression: >
	let &tagfunc = {t -> MyTagFunc(t)}

Set using a variable with lambda expression: >
	let L = {a, b, c -> MyTagFunc(a, b , c)}
	let &tagfunc = L

Calling a function in an expr option			*expr-option-function*

The value of a few options, such as 'foldexpr', is an expression that is
evaluated to get a value.  The evaluation can have quite a bit of overhead.
One way to minimize the overhead, and also to keep the option value very
simple, is to define a function and set the option to call it without
arguments.  A |v:lua-call| can also be used.  Example: >vim
	lua << EOF
	  function _G.MyFoldFunc()
	    -- ... compute fold level for line v:lnum
	    return level
	  end
	EOF
	set foldexpr=v:lua.MyFoldFunc()


Setting the filetype

:setf[iletype] [FALLBACK] {filetype}			*:setf* *:setfiletype*
			Set the 'filetype' option to {filetype}, but only if
			not done yet in a sequence of (nested) autocommands.
			This is short for: >
				:if !did_filetype()
				:  setlocal filetype={filetype}
				:endif
<			This command is used in a filetype.vim file to avoid
			setting the 'filetype' option twice, causing different
			settings and syntax files to be loaded.

			When the optional FALLBACK argument is present, a
			later :setfiletype command will override the
			'filetype'.  This is to be used for filetype
			detections that are just a guess.  |did_filetype()|
			will return false after this command.

				*option-window* *optwin*
:bro[wse] se[t]			*:set-browse* *:browse-set* *:opt* *:options*
:opt[ions]		Open a window for viewing and setting all options.
			Options are grouped by function.
			Offers short help for each option.  Hit <CR> on the
			short help to open a help window with more help for
			the option.
			Modify the value of the option and hit <CR> on the
			"set" line to set the new value.  For window and
			buffer specific options, the last accessed window is
			used to set the option value in, unless this is a help
			window, in which case the window below help window is
			used (skipping the option-window).

								*$HOME*
Using "~" is like using "$HOME", but it is only recognized at the start of an
option and after a space or comma.

On Unix systems "~user" can be used too.  It is replaced by the home directory
of user "user".  Example: >
    :set path=~mool/include,/usr/include,.

On Unix systems the form "${HOME}" can be used too.  The name between {} can
contain non-id characters then.  Note that if you want to use this for the
"gf" command,

Title: Advanced Option Settings: Functions, Filetypes, and the Options Window in Vim
Summary
This section details advanced option-setting techniques in Vim, including setting options to function names or references, especially useful for options like 'foldexpr'. It explains how to set the 'filetype' option conditionally using `:setfiletype` and the `did_filetype()` function. Additionally, it introduces the `:options` command for viewing and setting all options in a dedicated window and how to use "~" and "${HOME}" for path expansion within options.