Beware that evaluating an index may
cause an error message for an invalid
expression. E.g.: >vim
let l = [1, 2, 3]
echo exists("l[5]")
< 0 >vim
echo exists("l[xx]")
< E121: Undefined variable: xx
0
&option-name Vim option (only checks if it exists,
not if it really works)
+option-name Vim option that works.
$ENVNAME environment variable (could also be
done by comparing with an empty
string)
`*funcname` built-in function (see |functions|)
or user defined function (see
|user-function|). Also works for a
variable that is a Funcref.
:cmdname Ex command: built-in command, user
command or command modifier |:command|.
Returns:
1 for match with start of a command
2 full match with a command
3 matches several user commands
To check for a supported command
always check the return value to be 2.
:2match The |:2match| command.
:3match The |:3match| command (but you
probably should not use it, it is
reserved for internal usage)
#event autocommand defined for this event
#event#pattern autocommand defined for this event and
pattern (the pattern is taken
literally and compared to the
autocommand patterns character by
character)
#group autocommand group exists
#group#event autocommand defined for this group and
event.
#group#event#pattern
autocommand defined for this group,
event and pattern.
##event autocommand for this event is
supported.
Examples: >vim
echo exists("&mouse")
echo exists("$HOSTNAME")
echo exists("*strftime")
echo exists("*s:MyFunc")
echo exists("*MyFunc")
echo exists("*v:lua.Func")
echo exists("bufcount")
echo exists(":Make")
echo exists("#CursorHold")
echo exists("#BufReadPre#*.gz")
echo exists("#filetypeindent")
echo exists("#filetypeindent#FileType")
echo exists("#filetypeindent#FileType#*")
echo exists("##ColorScheme")
< There must be no space between the symbol (&/$/*/#) and the
name.
There must be no extra characters after the name, although in
a few cases this is ignored. That may become stricter in the
future, thus don't count on it!
Working example: >vim
echo exists(":make")
< NOT working example: >vim
echo exists(":make install")
< Note that the argument must be a string, not the name of the
variable itself. For example: >vim
echo exists(bufcount)
< This doesn't check for existence of the "bufcount" variable,
but gets the value of "bufcount", and checks if that exists.
Parameters: ~
• {expr} (`string`)
Return: ~
(`0|1`)
exp({expr}) *exp()*
Return the exponential of {expr} as a |Float| in the range
[0, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
Examples: >vim
echo exp(2)
< 7.389056 >vim
echo exp(-1)
< 0.367879
Parameters: ~
• {expr} (`number`)
Return: ~
(`any`)
expand({string} [, {nosuf} [, {list}]]) *expand()*
Expand wildcards and the following special keywords in
{string}. 'wildignorecase' applies.
If {list} is given and it is |TRUE|, a List will be returned.
Otherwise the result is a String and when there are several
matches, they are separated by <NL> characters.
If the expansion fails, the result is an empty string. A name
for a non-existing file is not included, unless {string} does
not start with '%', '#' or '<', see below.
When {string} starts with '%', '#' or '<', the expansion is
done like for the |cmdline-special| variables with their
associated modifiers. Here is a short overview:
% current file name
# alternate file name
#n alternate file name n
<cfile> file