aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/eval.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/eval.txt')
-rw-r--r--runtime/doc/eval.txt122
1 files changed, 76 insertions, 46 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 6a9fb6d03c..58759a6053 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4,7 +4,7 @@
VIM REFERENCE MANUAL by Bram Moolenaar
-Expression evaluation *expression* *expr* *E15* *eval*
+Expression evaluation *vimscript* *expression* *expr* *E15* *eval*
Using expressions is introduced in chapter 41 of the user manual |usr_41.txt|.
@@ -229,13 +229,13 @@ is not available it returns zero or the default value you specify: >
List concatenation ~
-
+ *list-concatenation*
Two lists can be concatenated with the "+" operator: >
:let longlist = mylist + [5, 6]
:let mylist += [7, 8]
-To prepend or append an item turn the item into a list by putting [] around
-it. To change a list in-place see |list-modification| below.
+To prepend or append an item, turn the item into a list by putting [] around
+it. To change a list in-place, refer to |list-modification| below.
Sublist ~
@@ -840,8 +840,8 @@ Example: >
All expressions within one level are parsed from left to right.
+------------------------------------------------------------------------------
expr1 *expr1* *ternary* *E109*
------
expr2 ? expr1 : expr1
@@ -867,8 +867,8 @@ You should always put a space before the ':', otherwise it can be mistaken for
use in a variable such as "a:1".
+------------------------------------------------------------------------------
expr2 and expr3 *expr2* *expr3*
----------------
expr3 || expr3 .. logical OR *expr-barbar*
expr4 && expr4 .. logical AND *expr-&&*
@@ -906,8 +906,8 @@ This is valid whether "b" has been defined or not. The second clause will
only be evaluated if "b" has been defined.
+------------------------------------------------------------------------------
expr4 *expr4*
------
expr5 {cmp} expr5
@@ -1010,8 +1010,9 @@ can be matched like an ordinary character. Examples:
"foo\nbar" =~ "\\n" evaluates to 0
+------------------------------------------------------------------------------
expr5 and expr6 *expr5* *expr6*
----------------
+
expr6 + expr6 Number addition, |List| or |Blob| concatenation *expr-+*
expr6 - expr6 Number subtraction *expr--*
expr6 . expr6 String concatenation *expr-.*
@@ -1064,8 +1065,9 @@ None of these work for |Funcref|s.
. and % do not work for Float. *E804*
+------------------------------------------------------------------------------
expr7 *expr7*
------
+
! expr7 logical NOT *expr-!*
- expr7 unary minus *expr-unary--*
+ expr7 unary plus *expr-unary-+*
@@ -1082,8 +1084,9 @@ These three can be repeated and mixed. Examples:
--9 == 9
+------------------------------------------------------------------------------
expr8 *expr8*
------
+
This expression is either |expr9| or a sequence of the alternatives below,
in any order. E.g., these are all possible:
expr8[expr1].name
@@ -1234,8 +1237,9 @@ When using the lambda form there must be no white space between the } and the
*expr9*
+------------------------------------------------------------------------------
number
-------
+
number number constant *expr-number*
*0x* *hex-number* *0o* *octal-number* *binary-number*
@@ -1297,9 +1301,9 @@ function. Example: >
< 7.853981633974483e-01
-
+------------------------------------------------------------------------------
string *string* *String* *expr-string* *E114*
-------
+
"string" string constant *expr-quote*
Note that double quotes are used.
@@ -1338,16 +1342,17 @@ encodings. Use "\u00ff" to store character 255 correctly as UTF-8.
Note that "\000" and "\x00" force the end of the string.
+------------------------------------------------------------------------------
blob-literal *blob-literal* *E973*
-------------
Hexadecimal starting with 0z or 0Z, with an arbitrary number of bytes.
The sequence must be an even number of hex characters. Example: >
:let b = 0zFF00ED015DAF
+------------------------------------------------------------------------------
literal-string *literal-string* *E115*
----------------
+
'string' string constant *expr-'*
Note that single quotes are used.
@@ -1361,8 +1366,9 @@ to be doubled. These two commands are equivalent: >
if a =~ '\s*'
+------------------------------------------------------------------------------
option *expr-option* *E112* *E113*
-------
+
&option option value, local value if possible
&g:option global option value
&l:option local option value
@@ -1376,8 +1382,9 @@ and there is no buffer-local or window-local value, the global value is used
anyway.
+------------------------------------------------------------------------------
register *expr-register* *@r*
---------
+
@r contents of register 'r'
The result is the contents of the named register, as a single string.
@@ -1394,8 +1401,9 @@ nesting *expr-nesting* *E110*
(expr1) nested expression
+------------------------------------------------------------------------------
environment variable *expr-env*
---------------------
+
$VAR environment variable
The String value of any environment variable. When it is not defined, the
@@ -1420,20 +1428,23 @@ The first one probably doesn't echo anything, the second echoes the $shell
variable (if your shell supports it).
+------------------------------------------------------------------------------
internal variable *expr-variable*
------------------
+
variable internal variable
See below |internal-variables|.
+------------------------------------------------------------------------------
function call *expr-function* *E116* *E118* *E119* *E120*
--------------
+
function(expr1, ...) function call
See below |functions|.
+------------------------------------------------------------------------------
lambda expression *expr-lambda* *lambda*
------------------
+
{args -> expr1} lambda expression
A lambda expression creates a new unnamed function which returns the result of
@@ -1524,7 +1535,7 @@ specified by what is prepended:
|tabpage-variable| t: Local to the current tab page.
|global-variable| g: Global.
|local-variable| l: Local to a function.
-|script-variable| s: Local to a |:source|'ed Vim script.
+|script-variable| s: Local to a |:source|d Vim script.
|function-argument| a: Function argument (only inside a function).
|vim-variable| v: Global, predefined by Vim.
@@ -1707,17 +1718,13 @@ v:charconvert_to
Only valid while evaluating the 'charconvert' option.
*v:cmdarg* *cmdarg-variable*
-v:cmdarg This variable is used for two purposes:
- 1. The extra arguments given to a file read/write command.
- Currently these are "++enc=" and "++ff=". This variable is
- set before an autocommand event for a file read/write
- command is triggered. There is a leading space to make it
- possible to append this variable directly after the
- read/write command. Note: The "+cmd" argument isn't
- included here, because it will be executed anyway.
- 2. When printing a PostScript file with ":hardcopy" this is
- the argument for the ":hardcopy" command. This can be used
- in 'printexpr'.
+v:cmdarg
+ The extra arguments ("++p", "++enc=", "++ff=") given to a file
+ read/write command. This is set before an autocommand event
+ for a file read/write command is triggered. There is a
+ leading space to make it possible to append this variable
+ directly after the read/write command. Note: "+cmd" isn't
+ included here, because it will be executed anyway.
*v:collate* *collate-variable*
v:collate The current locale setting for collation order of the runtime
@@ -1780,7 +1787,7 @@ v:exiting Exit code, or |v:null| before invoking the |VimLeavePre|
and |VimLeave| autocmds. See |:q|, |:x| and |:cquit|.
Example: >
:au VimLeave * echo "Exit value is " .. v:exiting
-
+<
*v:echospace* *echospace-variable*
v:echospace Number of screen cells that can be used for an `:echo` message
in the last screen line before causing the |hit-enter-prompt|.
@@ -1915,17 +1922,16 @@ v:fname_in The name of the input file. Valid while evaluating:
'charconvert' file to be converted
'diffexpr' original file
'patchexpr' original file
- 'printexpr' file to be printed
And set to the swap file name for |SwapExists|.
*v:fname_out* *fname_out-variable*
v:fname_out The name of the output file. Only valid while
evaluating:
option used for ~
- 'charconvert' resulting converted file (*)
+ 'charconvert' resulting converted file [1]
'diffexpr' output of diff
'patchexpr' resulting patched file
- (*) When doing conversion for a write command (e.g., ":w
+ [1] When doing conversion for a write command (e.g., ":w
file") it will be equal to v:fname_in. When doing conversion
for a read command (e.g., ":e file") it will be a temporary
file and different from v:fname_in.
@@ -1995,10 +2001,10 @@ v:lc_time The current locale setting for time messages of the runtime
command. See |multi-lang|.
*v:lnum* *lnum-variable*
-v:lnum Line number for the 'foldexpr' |fold-expr|, 'formatexpr' and
- 'indentexpr' expressions, tab page number for 'guitablabel'
- and 'guitabtooltip'. Only valid while one of these
- expressions is being evaluated. Read-only when in the
+v:lnum Line number for the 'foldexpr' |fold-expr|, 'formatexpr',
+ 'indentexpr' and 'statuscolumn' expressions, tab page number
+ for 'guitablabel' and 'guitabtooltip'. Only valid while one of
+ these expressions is being evaluated. Read-only when in the
|sandbox|.
*v:lua* *lua-variable*
@@ -2132,6 +2138,10 @@ v:register The name of the register in effect for the current normal mode
'*' or '+'.
Also see |getreg()| and |setreg()|
+ *v:relnum* *relnum-variable*
+v:relnum Relative line number for the 'statuscolumn' expression.
+ Read-only.
+
*v:scrollstart* *scrollstart-variable*
v:scrollstart String describing the script or function that caused the
screen to scroll up. It's only set when it is empty, thus the
@@ -2141,9 +2151,11 @@ v:scrollstart String describing the script or function that caused the
hit-enter prompt.
*v:servername* *servername-variable*
-v:servername Primary listen-address of the current Nvim instance, the first
- item returned by |serverlist()|. Can be set by |--listen| or
- |$NVIM_LISTEN_ADDRESS| (deprecated) at startup.
+v:servername Primary listen-address of Nvim, the first item returned by
+ |serverlist()|. Usually this is the named pipe created by Nvim
+ at |startup| or given by |--listen| (or the deprecated
+ |$NVIM_LISTEN_ADDRESS| env var).
+
See also |serverstart()| |serverstop()|.
Read-only.
@@ -2283,6 +2295,13 @@ v:version Vim version number: major version times 100 plus minor
:if has("nvim-0.2.1")
<
+ *v:virtnum* *virtnum-variable*
+v:virtnum Virtual line number for the 'statuscolumn' expression.
+ Negative when drawing the status column for virtual lines, zero
+ when drawing an actual buffer line, and positive when drawing
+ the wrapped part of a buffer line.
+ Read-only.
+
*v:vim_did_enter* *vim_did_enter-variable*
v:vim_did_enter 0 during startup, 1 just before |VimEnter|.
Read-only.
@@ -2662,6 +2681,8 @@ text...
[depth] is relevant when locking a |List| or
|Dictionary|. It specifies how deep the locking goes:
+ 0 Lock the variable {name} but not its
+ value.
1 Lock the |List| or |Dictionary| itself,
cannot add or remove items, but can
still change their values.
@@ -2675,7 +2696,14 @@ text...
|Dictionary|, one level deeper.
The default [depth] is 2, thus when {name} is a |List|
or |Dictionary| the values cannot be changed.
- *E743*
+
+ Example with [depth] 0: >
+ let mylist = [1, 2, 3]
+ lockvar 0 mylist
+ let mylist[0] = 77 " OK
+ call add(mylist, 4] " OK
+ let mylist = [7, 8, 9] " Error!
+< *E743*
For unlimited depth use [!] and omit [depth].
However, there is a maximum depth of 100 to catch
loops.
@@ -2696,6 +2724,8 @@ text...
Unlock the internal variable {name}. Does the
opposite of |:lockvar|.
+ No error is given if {name} does not exist.
+
:if {expr1} *:if* *:end* *:endif* *:en* *E171* *E579* *E580*
:en[dif] Execute the commands until the next matching `:else`
or `:endif` if {expr1} evaluates to non-zero.
@@ -3175,7 +3205,7 @@ this pending exception or command is discarded.
For examples see |throw-catch| and |try-finally|.
-NESTING OF TRY CONDITIONALS *try-nesting*
+NESTING OF TRY CONDITIONALS *try-nesting*
Try conditionals can be nested arbitrarily. That is, a complete try
conditional can be put into the try block, a catch clause, or the finally