Home Explore Blog CI



neovim

5th chunk of `runtime/doc/options.txt`
f354b875df0618824b07641c06c963fc84ddf5903a5f54350000000100000fa7
	Reason	~
	'filetype'	explicitly set by autocommands
	'syntax'	explicitly set by autocommands
	'bufhidden'	denote |special-buffers|
	'buftype'	denote |special-buffers|
	'readonly'	will be detected automatically
	'modified'	will be detected automatically

							*:setl* *:setlocal*
:setl[ocal][!] ...	Like ":set" but set only the value local to the
			current buffer or window.  Not all options have a
			local value.  If the option does not have a local
			value the global value is set.
			With the "all" argument: display local values for all
			local options.
			Without argument: Display local values for all local
			options which are different from the default.
			When displaying a specific local option, show the
			local value.  For a global/local boolean option, when
			the global value is being used, "--" is displayed
			before the option name.
			For a global option the global value is
			shown (but that might change in the future).

:se[t] {option}<	Set the effective value of {option} to its global
			value.
			For |global-local| options, the local value is removed,
			so that the global value will be used.
			For all other options, the global value is copied to
			the local value.

:setl[ocal] {option}<	Set the effective value of {option} to its global
			value by copying the global value to the local value.

Note that the behaviour for |global-local| options is slightly different
between string and number-based options.

							*:setg* *:setglobal*
:setg[lobal][!] ...	Like ":set" but set only the global value for a local
			option without changing the local value.
			When displaying an option, the global value is shown.
			With the "all" argument: display global values for all
			local options.
			Without argument: display global values for all local
			options which are different from the default.

For buffer-local and window-local options:
	Command		 global value	  local value	       condition ~
      :set option=value	     set	      set
 :setlocal option=value	      -		      set
:setglobal option=value	     set	       -
      :set option?	      -		     display	 local value is set
      :set option?	    display	       -	 local value is not set
 :setlocal option?	      -		     display
:setglobal option?	    display	       -


Global options with a local value			*global-local*

Options are global when you mostly use one value for all buffers and windows.
For some global options it's useful to sometimes have a different local value.
You can set the local value with ":setlocal".  That buffer or window will then
use the local value, while other buffers and windows continue using the global
value.

For example, you have two windows, both on C source code.  They use the global
'makeprg' option.  If you do this in one of the two windows: >
	:set makeprg=gmake
then the other window will switch to the same value.  There is no need to set
the 'makeprg' option in the other C source window too.
However, if you start editing a Perl file in a new window, you 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',

Title: Detailed Explanation of ':setlocal', ':setg', and Global-Local Options in Vim
Summary
This section explains the `:setlocal` and `:setglobal` commands, detailing how they interact with global and local options. It clarifies the behavior of global-local options, especially the differences between string and number-based options. The text also provides a detailed matrix showing how each command affects global and local option values under different conditions. It further illustrates the concept of global-local options with examples, showing how to set a local value with `:setlocal` and switch back to the global value. Finally, it mentions function-related options like 'completefunc'.