forked from aniani/vim
patch 8.1.1542: an OptionSet autocommand does not get enough info
Problem: An OptionSet autocommand does not get enough info.
Solution: Add v:option_command, v:option_oldlocal and v:option_oldglobal.
(Latrice Wilgus, closes #4118)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
*autocmd.txt* For Vim version 8.1. Last change: 2019 Jun 02
|
||||
*autocmd.txt* For Vim version 8.1. Last change: 2019 Jun 15
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -873,15 +873,33 @@ MenuPopup Just before showing the popup menu (under the
|
||||
*OptionSet*
|
||||
OptionSet After setting an option. The pattern is
|
||||
matched against the long option name.
|
||||
The |v:option_old| variable indicates the
|
||||
old option value, |v:option_new| variable
|
||||
indicates the newly set value, the
|
||||
|v:option_type| variable indicates whether
|
||||
it's global or local scoped and |<amatch>|
|
||||
indicates what option has been set.
|
||||
|<amatch>| indicates what option has been set.
|
||||
|
||||
Is not triggered on startup and for the 'key'
|
||||
option for obvious reasons.
|
||||
|v:option_type| indicates whether it's global
|
||||
or local scoped
|
||||
|v:option_command| indicates what type of
|
||||
set/let command was used (follow the tag to
|
||||
see the table).
|
||||
|v:option_new| indicates the newly set value.
|
||||
|v:option_oldlocal| hass the old local value.
|
||||
|v:option_oldglobal| hass the old global
|
||||
value
|
||||
|v:option_old| indicates the old option value.
|
||||
|
||||
|v:option_oldlocal| is only set when |:set|
|
||||
or |:setlocal| or a |modeline| was used to set
|
||||
the option. Similarly |v:option_oldglobal| is
|
||||
only set when |:set| or |:setglobal| was used.
|
||||
|
||||
Note that when setting a |global-local| string
|
||||
option with |:set|, then |v:option_old| is the
|
||||
old global value. However, for all other kinds
|
||||
of options (local string options, global-local
|
||||
number options, ...) it is the old local
|
||||
value.
|
||||
|
||||
OptionSet is not triggered on startup and for
|
||||
the 'key' option for obvious reasons.
|
||||
|
||||
Usage example: Check for the existence of the
|
||||
directory in the 'backupdir' and 'undodir'
|
||||
|
||||
@@ -1943,10 +1943,29 @@ v:option_new New value of the option. Valid while executing an |OptionSet|
|
||||
autocommand.
|
||||
*v:option_old*
|
||||
v:option_old Old value of the option. Valid while executing an |OptionSet|
|
||||
autocommand.
|
||||
autocommand. Depending on the command used for setting and the
|
||||
kind of option this is either the local old value or the
|
||||
global old value.
|
||||
*v:option_oldlocal*
|
||||
v:option_oldlocal
|
||||
Old local value of the option. Valid while executing an
|
||||
|OptionSet| autocommand.
|
||||
*v:option_oldglobal*
|
||||
v:option_oldglobal
|
||||
Old global value of the option. Valid while executing an
|
||||
|OptionSet| autocommand.
|
||||
*v:option_type*
|
||||
v:option_type Scope of the set command. Valid while executing an
|
||||
|OptionSet| autocommand. Can be either "global" or "local"
|
||||
*v:option_command*
|
||||
v:option_command
|
||||
Command used to set the option. Valid while executing an
|
||||
|OptionSet| autocommand.
|
||||
value option was set via ~
|
||||
"setlocal" |:setlocal| or ":let l:xxx"
|
||||
"setglobal" |:setglobal| or ":let g:xxx"
|
||||
"set" |:set| or |:let|
|
||||
"modeline" |modeline|
|
||||
*v:operator* *operator-variable*
|
||||
v:operator The last operator given in Normal mode. This is a single
|
||||
character except for commands starting with <g> or <z>,
|
||||
|
||||
@@ -336,7 +336,10 @@ New Vim variables: ~
|
||||
|v:null| an empty String, used for JSON
|
||||
|v:option_new| new value of the option, used by |OptionSet|
|
||||
|v:option_old| old value of the option, used by |OptionSet|
|
||||
|v:option_oldlocal| old local value of the option, used by |OptionSet|
|
||||
|v:option_oldglobal| old global value of the option, used by |OptionSet|
|
||||
|v:option_type| scope of the set command, used by |OptionSet|
|
||||
|v:option_command| command used to set the option, used by |OptionSet|
|
||||
|v:progpath| the command with which Vim was invoked
|
||||
|v:t_bool| value of Boolean type
|
||||
|v:t_channel| value of Channel type
|
||||
|
||||
Reference in New Issue
Block a user