1

In a new buffer, the expression &l:autoread evaluates to the value -1, indicating that the local option autoread has not yet been set with :setl autoread or :setl noautoread.

When I set the local option with :setl autoread, the expression evaluates to 1, when I unset it with :setl noautoread, it evaluates to 0. In either case, I won't be able to automatically have the global value for the option set with :set autoread.

So, is there a possibility to completely unset/delete the local option so that the expression &l:autoread will evaluate to -1 again?

  • What you describe seems odd. The normal value for the option is 0 or 1. Which version of vim are you using? – Luc Hermitte Jul 13 '16 at 12:14
  • @Luc, I double checked the behaviour, echo &l:autoread print -1 after starting up gvim. echo v:version prints 704. – René Nyffenegger Jul 13 '16 at 13:20
  • My mistake, I was testing &l:autochdir which is a global option. – Luc Hermitte Jul 13 '16 at 14:17
2

You could directly set the local option to -1:

setl autoread
let &l:autoread=-1

At this point echo &l:autoread returns -1, and setl autoread? outputs --autoread, which is the exact same output of a new buffer, meaning that the global value is being used for that option:

                                                        *:setl* *:setlocal*
:setl[ocal] ...         Like ":set" but set only the value local to the
                        (...)
                        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.

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.