1
- *builtin.txt* For Vim version 8.2. Last change: 2022 Mar 08
1
+ *builtin.txt* For Vim version 8.2. Last change: 2022 Apr 25
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -161,7 +161,8 @@ exists_compiled({expr}) Number |TRUE| if {expr} exists at compile time
161
161
exp({expr} ) Float exponential of {expr}
162
162
expand({expr} [, {nosuf} [, {list} ]])
163
163
any expand special keywords in {expr}
164
- expandcmd({expr} ) String expand {expr} like with `:edit `
164
+ expandcmd({string} [, {options} ])
165
+ String expand {string} like with `:edit `
165
166
extend({expr1} , {expr2} [, {expr3} ])
166
167
List/Dict insert items of {expr2} into {expr1}
167
168
extendnew({expr1} , {expr2} [, {expr3} ])
@@ -294,6 +295,7 @@ inputsecret({prompt} [, {text}]) String like input() but hiding the text
294
295
insert({object} , {item} [, {idx} ]) List insert {item} in {object} [before {idx} ]
295
296
interrupt() none interrupt script execution
296
297
invert({expr} ) Number bitwise invert
298
+ isabsolutepath({path} ) Number | TRUE | if {path} is an absolute path
297
299
isdirectory({directory} ) Number | TRUE | if {directory} is a directory
298
300
isinf({expr} ) Number determine if {expr} is infinity value
299
301
(positive or negative)
@@ -336,6 +338,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]])
336
338
rhs of mapping {name} in mode {mode}
337
339
mapcheck({name} [, {mode} [, {abbr} ]])
338
340
String check for mappings matching {name}
341
+ maplist([{abbr} ]) List list of all mappings, a dict for each
339
342
mapnew({expr1} , {expr2} ) List/Dict/Blob/String
340
343
like | map() | but creates a new List or
341
344
Dictionary
@@ -1562,14 +1565,15 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
1562
1565
or another valid interrupt key, confirm() returns 0.
1563
1566
1564
1567
An example: >
1565
- :let choice = confirm("What do you want?", "&Apples\n&Oranges\n&Bananas", 2)
1566
- :if choice == 0
1567
- : echo "make up your mind!"
1568
- :elseif choice == 3
1569
- : echo "tasteful"
1570
- :else
1571
- : echo "I prefer bananas myself."
1572
- :endif
1568
+ let choice = confirm("What do you want?",
1569
+ \ "&Apples\n&Oranges\n&Bananas", 2)
1570
+ if choice == 0
1571
+ echo "make up your mind!"
1572
+ elseif choice == 3
1573
+ echo "tasteful"
1574
+ else
1575
+ echo "I prefer bananas myself."
1576
+ endif
1573
1577
< In a GUI dialog, buttons are used. The layout of the buttons
1574
1578
depends on the 'v' flag in 'guioptions' . If it is included,
1575
1579
the buttons are always put vertically. Otherwise, confirm()
@@ -1752,7 +1756,10 @@ deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
1752
1756
1753
1757
delete({fname} [, {flags} ]) *delete()*
1754
1758
Without {flags} or with {flags} empty: Deletes the file by the
1755
- name {fname} . This also works when {fname} is a symbolic link.
1759
+ name {fname} .
1760
+
1761
+ This also works when {fname} is a symbolic link. The symbolic
1762
+ link itself is deleted, not what it points to.
1756
1763
1757
1764
When {flags} is "d": Deletes the directory by the name
1758
1765
{fname} . This fails when directory {fname} is not empty.
@@ -1762,8 +1769,6 @@ delete({fname} [, {flags}]) *delete()*
1762
1769
Note: on MS-Windows it is not possible to delete a directory
1763
1770
that is being used.
1764
1771
1765
- A symbolic link itself is deleted, not what it points to.
1766
-
1767
1772
The result is a Number, which is 0/false if the delete
1768
1773
operation was successful and -1/true when the deletion failed
1769
1774
or partly failed.
@@ -2043,7 +2048,7 @@ execute({command} [, {silent}]) *execute()*
2043
2048
It is not possible to use `:redir ` anywhere in {command} .
2044
2049
2045
2050
To get a list of lines use | split() | on the result: >
2046
- split( execute('args'), "\n")
2051
+ execute('args')->split( "\n")
2047
2052
2048
2053
< To execute a command in another window than the current one
2049
2054
use `win_execute ()` .
@@ -2234,6 +2239,8 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
2234
2239
a function
2235
2240
<SID> "<SNR> 123_" where "123" is the
2236
2241
current script ID | <SID> |
2242
+ <script> sourced script file, or script file
2243
+ where the current function was defined
2237
2244
<stack> call stack
2238
2245
<cword> word under the cursor
2239
2246
<cWORD> WORD under the cursor
@@ -2267,6 +2274,9 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
2267
2274
is not defined, an empty string is used. Using "%:p" in a
2268
2275
buffer with no name, results in the current directory, with a
2269
2276
'/' added.
2277
+ When 'verbose' is set then expanding '%', '#' and <> items
2278
+ will result in an error message if the argument cannot be
2279
+ expanded.
2270
2280
2271
2281
When {string} does not start with '%', '#' or '<', it is
2272
2282
expanded like a file name is expanded on the command line.
@@ -2292,16 +2302,28 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
2292
2302
Can also be used as a | method | : >
2293
2303
Getpattern()->expand()
2294
2304
2295
- expandcmd({string} ) *expandcmd()*
2305
+ expandcmd({string} [, {options} ]) *expandcmd()*
2296
2306
Expand special items in String {string} like what is done for
2297
2307
an Ex command such as `:edit ` . This expands special keywords,
2298
2308
like with | expand() | , and environment variables, anywhere in
2299
2309
{string} . "~user" and "~/path" are only expanded at the
2300
2310
start.
2301
- Returns the expanded string. Example: >
2302
- :echo expandcmd('make %<.o')
2303
2311
2304
- < Can also be used as a | method | : >
2312
+ The following items are supported in the {options} Dict
2313
+ argument:
2314
+ errmsg If set to TRUE, error messages are displayed
2315
+ if an error is encountered during expansion.
2316
+ By default, error messages are not displayed.
2317
+
2318
+ Returns the expanded string. If an error is encountered
2319
+ during expansion, the unmodified {string} is returned.
2320
+
2321
+ Example: >
2322
+ :echo expandcmd('make %<.o')
2323
+ make /path/runtime/doc/builtin.o
2324
+ :echo expandcmd('make %<.o', {'errmsg': v:true})
2325
+ <
2326
+ Can also be used as a | method | : >
2305
2327
GetCommand()->expandcmd()
2306
2328
<
2307
2329
extend({expr1} , {expr2} [, {expr3} ]) *extend()*
@@ -2397,7 +2419,8 @@ feedkeys({string} [, {mode}]) *feedkeys()*
2397
2419
all typeahead will be consumed by the last call.
2398
2420
'c' Remove any script context when executing, so that
2399
2421
legacy script syntax applies, "s:var" does not work,
2400
- etc.
2422
+ etc. Note that if the keys being using set a script
2423
+ context this still applies.
2401
2424
'!' When used with 'x' will not end Insert mode. Can be
2402
2425
used in a test when a timer is set to exit Insert mode
2403
2426
a little later. Useful for testing CursorHoldI.
@@ -2727,7 +2750,7 @@ foreground() Move the Vim window to the foreground. Useful when sent from
2727
2750
On Win32 systems this might not work, the OS does not always
2728
2751
allow a window to bring itself to the foreground. Use
2729
2752
| remote_foreground() | instead.
2730
- {only in the Win32, Athena, Motif and GTK GUI versions and the
2753
+ {only in the Win32, Motif and GTK GUI versions and the
2731
2754
Win32 console version}
2732
2755
2733
2756
fullcommand({name} ) *fullcommand()*
@@ -4650,6 +4673,24 @@ invert({expr}) *invert()*
4650
4673
< Can also be used as a | method | : >
4651
4674
:let bits = bits->invert()
4652
4675
4676
+ isabsolutepath({directory} ) *isabsolutepath()*
4677
+ The result is a Number, which is | TRUE | when {path} is an
4678
+ absolute path.
4679
+ < On Unix, a path is considered absolute when it starts with '/'.
4680
+ On MS-Windows, it is considered absolute when it starts with an
4681
+ optional drive prefix and is followed by a '\' or '/'. UNC paths
4682
+ are always absolute.
4683
+ Example: >
4684
+ echo isabsolutepath('/usr/share/') " 1
4685
+ echo isabsolutepath('./foobar') " 0
4686
+ echo isabsolutepath('C:\Windows') " 1
4687
+ echo isabsolutepath('foobar') " 0
4688
+ echo isabsolutepath('\\remote\file') " 1
4689
+
4690
+ Can also be used as a |method|: >
4691
+ GetName()->isabsolutepath()
4692
+
4693
+
4653
4694
isdirectory({directory} ) *isdirectory()*
4654
4695
The result is a Number, which is | TRUE | when a directory
4655
4696
with the name {directory} exists. If {directory} doesn't
@@ -4819,6 +4860,8 @@ json_encode({expr}) *json_encode()*
4819
4860
Note that NaN and Infinity are passed on as values. This is
4820
4861
missing in the JSON standard, but several implementations do
4821
4862
allow it. If not then you will get an error.
4863
+ If a string contains an illegal character then the replacement
4864
+ character 0xfffd is used.
4822
4865
4823
4866
Can also be used as a | method | : >
4824
4867
GetObject()->json_encode()
@@ -5213,7 +5256,8 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
5213
5256
When {dict} is omitted or zero: Return the rhs of mapping
5214
5257
{name} in mode {mode} . The returned String has special
5215
5258
characters translated like in the output of the ":map" command
5216
- listing.
5259
+ listing. When {dict} is TRUE a dictionary is returned, see
5260
+ below. To get a list of all mappings see | maplist() | .
5217
5261
5218
5262
When there is no mapping for {name} , an empty String is
5219
5263
returned. When the mapping for {name} is empty, then "<Nop> "
@@ -5240,7 +5284,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
5240
5284
5241
5285
When {dict} is there and it is | TRUE | return a dictionary
5242
5286
containing all the information of the mapping with the
5243
- following items:
5287
+ following items: *mapping-dict*
5244
5288
"lhs" The {lhs} of the mapping as it would be typed
5245
5289
"lhsraw" The {lhs} of the mapping as raw bytes
5246
5290
"lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
@@ -5314,6 +5358,18 @@ mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
5314
5358
GetKey()->mapcheck('n')
5315
5359
5316
5360
5361
+ maplist([{abbr} ]) *maplist()*
5362
+ Returns a | List | of all mappings. Each List item is a | Dict | ,
5363
+ the same as what is returned by | maparg() | , see
5364
+ | mapping-dict | . When {abbr} is there and it is | TRUE | use
5365
+ abbreviations instead of mappings.
5366
+
5367
+ Example to show all mappings with 'MultiMatch' in rhs: >
5368
+ vim9script
5369
+ echo maplist()->filter(
5370
+ (_, m) => match(m.rhs, 'MultiMatch') >= 0)
5371
+
5372
+
5317
5373
mapnew({expr1} , {expr2} ) *mapnew()*
5318
5374
Like | map() | but instead of replacing items in {expr1} a new
5319
5375
List or Dictionary is created and returned. {expr1} remains
@@ -5561,14 +5617,16 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
5561
5617
5562
5618
If {list} is a list of dictionaries, then the optional {dict}
5563
5619
argument supports the following additional items:
5564
- key key of the item which is fuzzy matched against
5620
+ key Key of the item which is fuzzy matched against
5565
5621
{str} . The value of this item should be a
5566
5622
string.
5567
5623
text_cb | Funcref | that will be called for every item
5568
5624
in {list} to get the text for fuzzy matching.
5569
5625
This should accept a dictionary item as the
5570
5626
argument and return the text for that item to
5571
5627
use for fuzzy matching.
5628
+ limit Maximum number of matches in {list} to be
5629
+ returned. Zero means no limit.
5572
5630
5573
5631
{str} is treated as a literal string and regular expression
5574
5632
matching is NOT supported. The maximum supported {str} length
@@ -5581,6 +5639,9 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
5581
5639
empty list is returned. If length of {str} is greater than
5582
5640
256, then returns an empty list.
5583
5641
5642
+ When {limit} is given, matchfuzzy() will find up to this
5643
+ number of matches in {list} and return them in sorted order.
5644
+
5584
5645
Refer to | fuzzy-matching | for more information about fuzzy
5585
5646
matching strings.
5586
5647
@@ -6009,8 +6070,10 @@ printf({fmt}, {expr1} ...) *printf()*
6009
6070
When used as a | method | the base is passed as the second
6010
6071
argument: >
6011
6072
Compute()->printf("result: %d")
6073
+ <
6074
+ You can use `call ()` to pass the items as a list.
6012
6075
6013
- < Often used items are:
6076
+ Often used items are:
6014
6077
%s string
6015
6078
%6S string right-aligned in 6 display cells
6016
6079
%6s string right-aligned in 6 bytes
@@ -6679,7 +6742,7 @@ remote_foreground({server}) *remote_foreground()*
6679
6742
Can also be used as a | method | : >
6680
6743
ServerName()->remote_foreground()
6681
6744
6682
- < {only in the Win32, Athena, Motif and GTK GUI versions and the
6745
+ < {only in the Win32, Motif and GTK GUI versions and the
6683
6746
Win32 console version}
6684
6747
6685
6748
@@ -10011,7 +10074,7 @@ footer Compiled with GUI footer support. |gui-footer|
10011
10074
fork Compiled to use fork()/exec() instead of system().
10012
10075
gettext Compiled with message translation | multi-lang |
10013
10076
gui Compiled with GUI enabled.
10014
- gui_athena Compiled with Athena GUI.
10077
+ gui_athena Compiled with Athena GUI (always false) .
10015
10078
gui_gnome Compiled with Gnome support (gui_gtk is also defined).
10016
10079
gui_gtk Compiled with GTK+ GUI (any version).
10017
10080
gui_gtk2 Compiled with GTK+ 2 GUI (gui_gtk is also defined).
0 commit comments