Global options apply to all of vim, and local options apply only to the current window/buffer. To set a global option, use :setglobal
. To set a local option, which preserves the global option but overwrites for the current window, use :setlocal
.
:set
defaults to local when inside a file, and global when not. The syntax works like:
:set[local|global] [option]=[value]
An example:
:setlocal syntax=0
You can also set options with let
, use prepend &
before the g
/l
, like
:let &[g|l]:optionname
My old answer, for variables:
In this case, local means specific to the current window/buffer/tab/function. Global means vim-wide (in that instance).
To set a global variable, use:
:let g:var = 0
:echo var
(the echo just outputs the value, of course)
To set a local variable, use w
, b
, t
, s
, or l
instead of g
in g:var
.
w
is for the current window, b
is for the current buffer, t
is the current tab, s
is the current script, and l
is the current function.
If you don't use a prefix, it defaults to global (but l
if inside a function).