1- *eval.txt* For Vim version 8.2. Last change: 2020 Jun 07
1+ *eval.txt* For Vim version 8.2. Last change: 2020 Jun 14
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1533,6 +1533,7 @@ An internal variable is explicitly destroyed with the ":unlet" command
15331533Using a name that is not an internal variable or refers to a variable that has
15341534been destroyed results in an error.
15351535
1536+ *variable-scope*
15361537There are several name spaces for variables. Which one is to be used is
15371538specified by what is prepended:
15381539
@@ -1551,7 +1552,9 @@ delete all script-local variables: >
15511552 :for k in keys(s:)
15521553 : unlet s:[k]
15531554 :endfor
1554- <
1555+
1556+ Note: in Vim9 script this is different, see |vim9-scopes|.
1557+
15551558 *buffer-variable* *b:var* *b:*
15561559A variable name that is preceded with "b:" is local to the current buffer.
15571560Thus you can have several "b:foo" variables, one for each buffer.
@@ -1742,6 +1745,14 @@ v:cmdbang Set like v:cmdarg for a file read/write command. When a "!"
17421745 was used the value is 1, otherwise it is 0. Note that this
17431746 can only be used in autocommands. For user commands |<bang>|
17441747 can be used.
1748+ *v:collate* *collate-variable*
1749+ v:collate The current locale setting for collation order of the runtime
1750+ environment. This allows Vim scripts to be aware of the
1751+ current locale encoding. Technical: it's the value of
1752+ LC_COLLATE. When not using a locale the value is "C".
1753+ This variable can not be set directly, use the |:language|
1754+ command.
1755+ See |multi-lang|.
17451756
17461757 *v:completed_item* *completed_item-variable*
17471758v:completed_item
@@ -2206,7 +2217,8 @@ v:termresponse The escape sequence returned by the terminal for the |t_RV|
22062217 'c', with only digits and ';' in between.
22072218 When this option is set, the TermResponse autocommand event is
22082219 fired, so that you can react to the response from the
2209- terminal.
2220+ terminal. You can use |terminalprops()| to see what Vim
2221+ figured out about the terminal.
22102222 The response from a new xterm is: "<Esc>[> Pp ; Pv ; Pc c". Pp
22112223 is the terminal type: 0 for vt100 and 1 for vt220. Pv is the
22122224 patch level (since this was introduced in patch 95, it's
@@ -2691,8 +2703,10 @@ pyxeval({expr}) any evaluate |python_x| expression
26912703rand([{expr}]) Number get pseudo-random number
26922704range({expr} [, {max} [, {stride}]])
26932705 List items from {expr} to {max}
2694- readdir({dir} [, {expr}]) List file names in {dir} selected by {expr}
2695- readdirex({dir} [, {expr}]) List file info in {dir} selected by {expr}
2706+ readdir({dir} [, {expr} [, {dict}]])
2707+ List file names in {dir} selected by {expr}
2708+ readdirex({dir} [, {expr} [, {dict}]])
2709+ List file info in {dir} selected by {expr}
26962710readfile({fname} [, {type} [, {max}]])
26972711 List get list of lines from file {fname}
26982712reduce({object}, {func} [, {initial}])
@@ -2882,6 +2896,7 @@ term_setsize({buf}, {rows}, {cols})
28822896 none set the size of a terminal
28832897term_start({cmd} [, {options}]) Number open a terminal window and run a job
28842898term_wait({buf} [, {time}]) Number wait for screen to be updated
2899+ terminalprops() Dict properties of the terminal
28852900test_alloc_fail({id}, {countdown}, {repeat})
28862901 none make memory allocation fail
28872902test_autochdir() none enable 'autochdir' during startup
@@ -4533,7 +4548,7 @@ flatten({list} [, {maxdepth}]) *flatten()*
45334548 a very large number.
45344549 The {list} is changed in place, make a copy first if you do
45354550 not want that.
4536- *E964 *
4551+ *E900 *
45374552 {maxdepth} means how deep in nested lists changes are made.
45384553 {list} is not modified when {maxdepth} is 0.
45394554 {maxdepth} must be positive number.
@@ -6288,10 +6303,11 @@ inputlist({textlist}) *inputlist()*
62886303 displayed, one string per line. The user will be prompted to
62896304 enter a number, which is returned.
62906305 The user can also select an item by clicking on it with the
6291- mouse. For the first string 0 is returned. When clicking
6292- above the first item a negative number is returned. When
6293- clicking on the prompt one more than the length of {textlist}
6294- is returned.
6306+ mouse, if the mouse is enabled in the command line ('mouse' is
6307+ "a" or includes "c"). For the first string 0 is returned.
6308+ When clicking above the first item a negative number is
6309+ returned. When clicking on the prompt one more than the
6310+ length of {textlist} is returned.
62956311 Make sure {textlist} has less than 'lines' entries, otherwise
62966312 it won't work. It's a good idea to put the entry number at
62976313 the start of the string. And put a prompt in the first item.
@@ -7910,11 +7926,12 @@ rand([{expr}]) *rand()* *random*
79107926 :echo rand(seed)
79117927 :echo rand(seed) % 16 " random number 0 - 15
79127928<
7913- readdir({directory} [, {expr}]) *readdir()*
7929+ readdir({directory} [, {expr} [, {dict}]]) *readdir()*
79147930 Return a list with file and directory names in {directory}.
79157931 You can also use |glob()| if you don't need to do complicated
79167932 things, such as limiting the number of matches.
7917- The list will be sorted (case sensitive).
7933+ The list will be sorted (case sensitive), see the {dict}
7934+ argument below for changing the sort order.
79187935
79197936 When {expr} is omitted all entries are included.
79207937 When {expr} is given, it is evaluated to check what to do:
@@ -7932,18 +7949,38 @@ readdir({directory} [, {expr}]) *readdir()*
79327949< To skip hidden and backup files: >
79337950 readdir(dirname, {n -> n !~ '^\.\|\~$'})
79347951
7952+ < The optional {dict} argument allows for further custom
7953+ values. Currently this is used to specify if and how sorting
7954+ should be performed. The dict can have the following members:
7955+
7956+ sort How to sort the result returned from the system.
7957+ Valid values are:
7958+ "none" do not sort (fastest method)
7959+ "case" sort case sensitive (byte value of
7960+ each character, technically, using
7961+ strcmp()) (default)
7962+ "icase" sort case insensitive (technically
7963+ using strcasecmp())
7964+ "collate" sort using the collation order
7965+ of the "POSIX" or "C" |locale|
7966+ (technically using strcoll())
7967+ Other values are silently ignored.
7968+
7969+ For example, to get a list of all files in the current
7970+ directory without sorting the individual entries: >
7971+ readdir('.', '1', #{sort: 'none'})
79357972< If you want to get a directory tree: >
7936- function! s:tree(dir)
7937- return {a:dir : map(readdir(a:dir),
7973+ function! s:tree(dir)
7974+ return {a:dir : map(readdir(a:dir),
79387975 \ {_, x -> isdirectory(x) ?
7939- \ {x : s:tree(a:dir . '/' . x)} : x})}
7940- endfunction
7941- echo s:tree(".")
7976+ \ {x : s:tree(a:dir . '/' . x)} : x})}
7977+ endfunction
7978+ echo s:tree(".")
79427979<
79437980 Can also be used as a |method|: >
79447981 GetDirName()->readdir()
79457982<
7946- readdirex({directory} [, {expr}]) *readdirex()*
7983+ readdirex({directory} [, {expr} [, {dict}] ]) *readdirex()*
79477984 Extended version of |readdir()|.
79487985 Return a list of Dictionaries with file and directory
79497986 information in {directory}.
@@ -7952,7 +7989,9 @@ readdirex({directory} [, {expr}]) *readdirex()*
79527989 This is much faster than calling |readdir()| then calling
79537990 |getfperm()|, |getfsize()|, |getftime()| and |getftype()| for
79547991 each file and directory especially on MS-Windows.
7955- The list will be sorted by name (case sensitive).
7992+ The list will by default be sorted by name (case sensitive),
7993+ the sorting can be changed by using the optional {dict}
7994+ argument, see |readdir()|.
79567995
79577996 The Dictionary for file and directory information has the
79587997 following items:
@@ -7992,6 +8031,11 @@ readdirex({directory} [, {expr}]) *readdirex()*
79928031 When {expr} is a function the entry is passed as the argument.
79938032 For example, to get a list of files ending in ".txt": >
79948033 readdirex(dirname, {e -> e.name =~ '.txt$'})
8034+ <
8035+ For example, to get a list of all files in the current
8036+ directory without sorting the individual entries: >
8037+ readdirex(dirname, '1', #{sort: 'none'})
8038+
79958039<
79968040 Can also be used as a |method|: >
79978041 GetDirName()->readdirex()
@@ -10402,6 +10446,41 @@ tempname() *tempname()* *temp-file-name*
1040210446
1040310447term_ functions are documented here: |terminal-function-details|
1040410448
10449+
10450+ terminalprops() *terminalprops()*
10451+ Returns a dictionary with properties of the terminal that Vim
10452+ detected from the response to |t_RV| request. See
10453+ |v:termresponse| for the response itself. If |v:termresponse|
10454+ is empty most values here will be 'u' for unknown.
10455+ cursor_style wether sending |t_RS| works **
10456+ cursor_blink_mode wether sending |t_RC| works **
10457+ underline_rgb whether |t_8u| works **
10458+ mouse mouse type supported
10459+
10460+ ** value 'u' for unknown, 'y' for yes, 'n' for no
10461+
10462+ If the |+termresponse| feature is missing then the result is
10463+ an empty dictionary.
10464+
10465+ If "cursor_style" is 'y' then |t_RS| will be send to request the
10466+ current cursor style.
10467+ If "cursor_blink_mode" is 'y' then |t_RC| will be send to
10468+ request the cursor blink status.
10469+ "cursor_style" and "cursor_blink_mode" are also set if |t_u7|
10470+ is not empty, Vim will detect the working of sending |t_RS|
10471+ and |t_RC| on startup.
10472+
10473+ When "underline_rgb" is not 'y', then |t_8u| will be made empty.
10474+ This avoids sending it to xterm, which would clear the colors.
10475+
10476+ For "mouse" the value 'u' is unknown
10477+
10478+ Also see:
10479+ - 'ambiwidth' - detected by using |t_u7|.
10480+ - |v:termstyleresp| and |v:termblinkresp| for the response to
10481+ |t_RS| and |t_RC|.
10482+
10483+
1040510484test_ functions are documented here: |test-functions-details|
1040610485
1040710486
@@ -10797,7 +10876,10 @@ win_getid([{win} [, {tab}]]) *win_getid()*
1079710876
1079810877win_gettype([{nr}]) *win_gettype()*
1079910878 Return the type of the window:
10879+ "autocmd" autocommand window. Temporary window
10880+ used to execute autocommands.
1080010881 "popup" popup window |popup|
10882+ "preview" preview window |preview-window|
1080110883 "command" command-line window |cmdwin|
1080210884 (empty) normal window
1080310885 "unknown" window {nr} not found
@@ -11763,6 +11845,9 @@ like this: >
1176311845
1176411846 :call filename#funcname()
1176511847
11848+ These functions are always global, in Vim9 script "g:" needs to be used: >
11849+ :call g:filename#funcname()
11850+
1176611851When such a function is called, and it is not defined yet, Vim will search the
1176711852"autoload" directories in 'runtimepath' for a script file called
1176811853"filename.vim". For example "~/.vim/autoload/filename.vim". That file should
@@ -11774,7 +11859,11 @@ then define the function like this: >
1177411859
1177511860The file name and the name used before the # in the function must match
1177611861exactly, and the defined function must have the name exactly as it will be
11777- called.
11862+ called. In Vim9 script the "g:" prefix must be used: >
11863+ function g:filename#funcname()
11864+
11865+ or for a compiled function: >
11866+ def g:filename#funcname()
1177811867
1177911868It is possible to use subdirectories. Every # in the function name works like
1178011869a path separator. Thus when calling a function: >
@@ -11857,6 +11946,9 @@ This does NOT work: >
1185711946==============================================================================
11858119477. Commands *expression-commands*
1185911948
11949+ Note: in Vim9 script `:let` is used for variable declaration, not assignment.
11950+ An assignment leaves out the `:let` command. |vim9-declaration|
11951+
1186011952:let {var-name} = {expr1} *:let* *E18*
1186111953 Set internal variable {var-name} to the result of the
1186211954 expression {expr1}. The variable will get the type
@@ -12079,12 +12171,14 @@ text...
1207912171 s: script-local variables
1208012172 l: local function variables
1208112173 v: Vim variables.
12174+ This does not work in Vim9 script. |vim9-declaration|
1208212175
1208312176:let List the values of all variables. The type of the
1208412177 variable is indicated before the value:
1208512178 <nothing> String
1208612179 # Number
1208712180 * Funcref
12181+ This does not work in Vim9 script. |vim9-declaration|
1208812182
1208912183:unl[et][!] {name} ... *:unlet* *:unl* *E108* *E795*
1209012184 Remove the internal variable {name}. Several variable
0 commit comments