From :h 'ar':

...If this option has a local value, use this command to switch back to using the global value: :set autoread<

What do local & global value exactly mean?

I have searched about global & local value but no desired answer, on the other hand if there is no FAQ reference for this subject this question can be, so please let me know what are differs between local & global value. Thanks.


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).

| improve this answer | |
  • I believe the question is about setting options locally and globally, i.e. setlocal vs setglobal vs set. See :h :setglobal, :h local-options, :h global-local. Although you can also set options with :let. e.g. let &l:option_name or globally let &g:option_name. See :h :let-option – Peter Rincker Dec 20 '17 at 18:12
  • @PeterRincker ah, I thought it was about variables (obviously). I'll update my answer in a bit. – user11389 Dec 20 '17 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.