aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/builtin.txt2857
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua2839
-rwxr-xr-xscripts/gen_eval_files.lua16
-rw-r--r--src/nvim/eval.lua3115
4 files changed, 4650 insertions, 4177 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 0e49c70470..3033435ee6 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -17,16 +17,17 @@ abs({expr}) *abs()*
a |Float| abs() returns a |Float|. When {expr} can be
converted to a |Number| abs() returns a |Number|. Otherwise
abs() gives an error message and returns -1.
- Examples: >
+ Examples: >vim
echo abs(1.456)
-< 1.456 >
+< 1.456 >vim
echo abs(-5.456)
-< 5.456 >
+< 5.456 >vim
echo abs(-4)
< 4
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->abs()
+<
acos({expr}) *acos()*
Return the arc cosine of {expr} measured in radians, as a
@@ -35,43 +36,47 @@ acos({expr}) *acos()*
[-1, 1].
Returns NaN if {expr} is outside the range [-1, 1]. Returns
0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo acos(0)
-< 1.570796 >
- :echo acos(-0.5)
+ Examples: >vim
+ echo acos(0)
+< 1.570796 >vim
+ echo acos(-0.5)
< 2.094395
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->acos()
+<
add({object}, {expr}) *add()*
Append the item {expr} to |List| or |Blob| {object}. Returns
- the resulting |List| or |Blob|. Examples: >
- :let alist = add([1, 2, 3], item)
- :call add(mylist, "woodstock")
+ the resulting |List| or |Blob|. Examples: >vim
+ let alist = add([1, 2, 3], item)
+ call add(mylist, "woodstock")
< Note that when {expr} is a |List| it is appended as a single
item. Use |extend()| to concatenate |Lists|.
When {object} is a |Blob| then {expr} must be a number.
Use |insert()| to add an item at another position.
Returns 1 if {object} is not a |List| or a |Blob|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->add(val1)->add(val2)
+<
and({expr}, {expr}) *and()*
Bitwise AND on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see `or()` and `xor()`.
- Example: >
- :let flag = and(bits, 0x80)
-< Can also be used as a |method|: >
- :let flag = bits->and(0x80)
+ Example: >vim
+ let flag = and(bits, 0x80)
+< Can also be used as a |method|: >vim
+ let flag = bits->and(0x80)
+<
api_info() *api_info()*
Returns Dictionary of |api-metadata|.
- View it in a nice human-readable format: >
- :lua vim.print(vim.fn.api_info())
+ View it in a nice human-readable format: >vim
+ lua vim.print(vim.fn.api_info())
+<
append({lnum}, {text}) *append()*
When {text} is a |List|: Append each item of the |List| as a
@@ -82,12 +87,13 @@ append({lnum}, {text}) *append()*
{lnum} can be zero to insert a line before the first one.
{lnum} is used like with |getline()|.
Returns 1 for failure ({lnum} out of range or out of memory),
- 0 for success. Example: >
- :let failed = append(line('$'), "# THE END")
- :let failed = append(0, ["Chapter 1", "the beginning"])
+ 0 for success. Example: >vim
+ let failed = append(line('$'), "# THE END")
+ let failed = append(0, ["Chapter 1", "the beginning"])
-< Can also be used as a |method| after a List: >
+< Can also be used as a |method| after a List: >vim
mylist->append(lnum)
+<
appendbufline({buf}, {lnum}, {text}) *appendbufline()*
Like |append()| but append the text in buffer {expr}.
@@ -105,11 +111,12 @@ appendbufline({buf}, {lnum}, {text}) *appendbufline()*
On success 0 is returned, on failure 1 is returned.
If {buf} is not a valid buffer or {lnum} is not valid, an
- error message is given. Example: >
- :let failed = appendbufline(13, 0, "# THE START")
+ error message is given. Example: >vim
+ let failed = appendbufline(13, 0, "# THE START")
<
- Can also be used as a |method| after a List: >
+ Can also be used as a |method| after a List: >vim
mylist->appendbufline(buf, lnum)
+<
argc([{winid}]) *argc()*
The result is the number of files in the argument list. See
@@ -139,13 +146,13 @@ arglistid([{winnr} [, {tabnr}]]) *arglistid()*
argv([{nr} [, {winid}]]) *argv()*
The result is the {nr}th file in the argument list. See
- |arglist|. "argv(0)" is the first one. Example: >
- :let i = 0
- :while i < argc()
- : let f = escape(fnameescape(argv(i)), '.')
- : exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
- : let i = i + 1
- :endwhile
+ |arglist|. "argv(0)" is the first one. Example: >vim
+ let i = 0
+ while i < argc()
+ let f = escape(fnameescape(argv(i)), '.')
+ exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
+ let i = i + 1
+ endwhile
< Without the {nr} argument, or when {nr} is -1, a |List| with
the whole |arglist| is returned.
@@ -163,13 +170,13 @@ asin({expr}) *asin()*
[-1, 1].
Returns NaN if {expr} is outside the range [-1, 1]. Returns
0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo asin(0.8)
-< 0.927295 >
- :echo asin(-0.5)
+ Examples: >vim
+ echo asin(0.8)
+< 0.927295 >vim
+ echo asin(-0.5)
< -0.523599
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->asin()
<
@@ -179,7 +186,7 @@ assert_beeps({cmd}) *assert_beeps()*
Also see |assert_fails()|, |assert_nobeep()| and
|assert-return|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCmd()->assert_beeps()
<
@@ -194,13 +201,14 @@ assert_equal({expected}, {actual} [, {msg}]) *assert_equal()*
from the Number 4. And the number 4 is different from the
Float 4.0. The value of 'ignorecase' is not used here, case
always matters.
- Example: >
+ Example: >vim
assert_equal('foo', 'bar')
< Will result in a string to be added to |v:errors|:
test.vim line 12: Expected 'foo' but got 'bar' ~
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->assert_equal([1, 2, 3])
+<
assert_equalfile({fname-one}, {fname-two}) *assert_equalfile()*
When the files {fname-one} and {fname-two} do not contain
@@ -209,15 +217,16 @@ assert_equalfile({fname-one}, {fname-two}) *assert_equalfile()*
When {fname-one} or {fname-two} does not exist the error will
mention that.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLog()->assert_equalfile('expected.log')
+<
assert_exception({error} [, {msg}]) *assert_exception()*
When v:exception does not contain the string {error} an error
message is added to |v:errors|. Also see |assert-return|.
This can be used to assert that a command throws an exception.
Using the error number, followed by a colon, avoids problems
- with translations: >
+ with translations: >vim
try
commandthatfails
call assert_false(1, 'command should have failed')
@@ -234,16 +243,16 @@ assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
When {error} is a string it must be found literally in the
first reported error. Most often this will be the error code,
- including the colon, e.g. "E123:". >
+ including the colon, e.g. "E123:". >vim
assert_fails('bad cmd', 'E987:')
<
When {error} is a |List| with one or two strings, these are
used as patterns. The first pattern is matched against the
- first reported error: >
+ first reported error: >vim
assert_fails('cmd', ['E987:.*expected bool'])
< The second pattern, if present, is matched against the last
reported error. To only match the last error use an empty
- string for the first error: >
+ string for the first error: >vim
assert_fails('cmd', ['', 'E987:'])
<
If {msg} is empty then it is not used. Do this to get the
@@ -261,8 +270,9 @@ assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
Note that beeping is not considered an error, and some failing
commands only beep. Use |assert_beeps()| for those.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCmd()->assert_fails('E99:')
+<
assert_false({actual} [, {msg}]) *assert_false()*
When {actual} is not false an error message is added to
@@ -274,8 +284,9 @@ assert_false({actual} [, {msg}]) *assert_false()*
A value is false when it is zero. When {actual} is not a
number the assert fails.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetResult()->assert_false()
+<
assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
This asserts number and |Float| values. When {actual} is lower
@@ -299,12 +310,12 @@ assert_match({pattern}, {actual} [, {msg}]) *assert_match()*
Use "^" and "$" to match with the start and end of the text.
Use both to match the whole text.
- Example: >
+ Example: >vim
assert_match('^f.*o$', 'foobar')
< Will result in a string to be added to |v:errors|:
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
getFile()->assert_match('foo.*')
<
@@ -313,7 +324,7 @@ assert_nobeep({cmd}) *assert_nobeep()*
produces a beep or visual bell.
Also see |assert_beeps()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCmd()->assert_nobeep()
<
@@ -322,9 +333,8 @@ assert_notequal({expected}, {actual} [, {msg}]) *assert_notequal()*
|v:errors| when {expected} and {actual} are equal.
Also see |assert-return|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->assert_notequal([1, 2, 3])
-
<
assert_notmatch({pattern}, {actual} [, {msg}]) *assert_notmatch()*
@@ -332,7 +342,7 @@ assert_notmatch({pattern}, {actual} [, {msg}]) *assert_notmatch()*
|v:errors| when {pattern} matches {actual}.
Also see |assert-return|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
getFile()->assert_notmatch('bar.*')
<
@@ -340,7 +350,7 @@ assert_report({msg}) *assert_report()*
Report a test failure directly, using String {msg}.
Always returns one.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMessage()->assert_report()
<
@@ -352,7 +362,7 @@ assert_true({actual} [, {msg}]) *assert_true()*
When {actual} is not a number or |v:true| the assert fails.
When {msg} is given it precedes the default message.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetResult()->assert_true()
<
@@ -361,14 +371,15 @@ atan({expr}) *atan()*
the range [-pi/2, +pi/2] radians, as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo atan(100)
-< 1.560797 >
- :echo atan(-4.01)
+ Examples: >vim
+ echo atan(100)
+< 1.560797 >vim
+ echo atan(-4.01)
< -1.326405
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->atan()
+<
atan2({expr1}, {expr2}) *atan2()*
Return the arc tangent of {expr1} / {expr2}, measured in
@@ -376,24 +387,25 @@ atan2({expr1}, {expr2}) *atan2()*
{expr1} and {expr2} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
|Number|.
- Examples: >
- :echo atan2(-1, 1)
-< -0.785398 >
- :echo atan2(1, -1)
+ Examples: >vim
+ echo atan2(-1, 1)
+< -0.785398 >vim
+ echo atan2(1, -1)
< 2.356194
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->atan2(1)
+<
blob2list({blob}) *blob2list()*
Return a List containing the number value of each byte in Blob
- {blob}. Examples: >
- blob2list(0z0102.0304) returns [1, 2, 3, 4]
- blob2list(0z) returns []
+ {blob}. Examples: >vim
+ blob2list(0z0102.0304) " returns [1, 2, 3, 4]
+ blob2list(0z) " returns []
< Returns an empty List on error. |list2blob()| does the
opposite.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBlob()->blob2list()
<
@@ -428,13 +440,14 @@ bufadd({name}) *bufadd()*
created buffer. When {name} is an empty string then a new
buffer is always created.
The buffer will not have 'buflisted' set and not be loaded
- yet. To add some text to the buffer use this: >
+ yet. To add some text to the buffer use this: >vim
let bufnr = bufadd('someName')
call bufload(bufnr)
call setbufline(bufnr, 1, ['some', 'text'])
< Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let bufnr = 'somename'->bufadd()
+<
bufexists({buf}) *bufexists()*
The result is a Number, which is |TRUE| if a buffer called
@@ -458,16 +471,18 @@ bufexists({buf}) *bufexists()*
Use "bufexists(0)" to test for the existence of an alternate
file name.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let exists = 'somename'->bufexists()
+<
buflisted({buf}) *buflisted()*
The result is a Number, which is |TRUE| if a buffer called
{buf} exists and is listed (has the 'buflisted' option set).
The {buf} argument is used like with |bufexists()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let listed = 'somename'->buflisted()
+<
bufload({buf}) *bufload()*
Ensure the buffer {buf} is loaded. When the buffer name
@@ -479,16 +494,18 @@ bufload({buf}) *bufload()*
there will be no dialog, the buffer will be loaded anyway.
The {buf} argument is used like with |bufexists()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
eval 'somename'->bufload()
+<
bufloaded({buf}) *bufloaded()*
The result is a Number, which is |TRUE| if a buffer called
{buf} exists and is loaded (shown in a window or hidden).
The {buf} argument is used like with |bufexists()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let loaded = 'somename'->bufloaded()
+<
bufname([{buf}]) *bufname()*
The result is the name of a buffer. Mostly as it is displayed
@@ -511,17 +528,17 @@ bufname([{buf}]) *bufname()*
with a listed buffer, that one is returned. Next unlisted
buffers are searched for.
If the {buf} is a String, but you want to use it as a buffer
- number, force it to be a Number by adding zero to it: >
- :echo bufname("3" + 0)
-< Can also be used as a |method|: >
+ number, force it to be a Number by adding zero to it: >vim
+ echo bufname("3" + 0)
+< Can also be used as a |method|: >vim
echo bufnr->bufname()
< If the buffer doesn't exist, or doesn't have a name, an empty
- string is returned. >
- bufname("#") alternate buffer name
- bufname(3) name of buffer 3
- bufname("%") name of current buffer
- bufname("file2") name of buffer where "file2" matches.
+ string is returned. >vim
+ echo bufname("#") " alternate buffer name
+ echo bufname(3) " name of buffer 3
+ echo bufname("%") " name of current buffer
+ echo bufname("file2") " name of buffer where "file2" matches.
<
bufnr([{buf} [, {create}]]) *bufnr()*
@@ -531,43 +548,46 @@ bufnr([{buf} [, {create}]]) *bufnr()*
If the buffer doesn't exist, -1 is returned. Or, if the
{create} argument is present and TRUE, a new, unlisted,
buffer is created and its number is returned.
- bufnr("$") is the last buffer: >
- :let last_buffer = bufnr("$")
+ bufnr("$") is the last buffer: >vim
+ let last_buffer = bufnr("$")
< The result is a Number, which is the highest buffer number
of existing buffers. Note that not all buffers with a smaller
number necessarily exist, because ":bwipeout" may have removed
them. Use bufexists() to test for the existence of a buffer.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
echo bufref->bufnr()
+<
bufwinid({buf}) *bufwinid()*
The result is a Number, which is the |window-ID| of the first
window associated with buffer {buf}. For the use of {buf},
see |bufname()| above. If buffer {buf} doesn't exist or
- there is no such window, -1 is returned. Example: >
+ there is no such window, -1 is returned. Example: >vim
echo "A window containing buffer 1 is " .. (bufwinid(1))
<
Only deals with the current tab page. See |win_findbuf()| for
finding more.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
FindBuffer()->bufwinid()
+<
bufwinnr({buf}) *bufwinnr()*
Like |bufwinid()| but return the window number instead of the
|window-ID|.
If buffer {buf} doesn't exist or there is no such window, -1
- is returned. Example: >
+ is returned. Example: >vim
echo "A window containing buffer 1 is " .. (bufwinnr(1))
< The number can be used with |CTRL-W_w| and ":wincmd w"
|:wincmd|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
FindBuffer()->bufwinnr()
+<
byte2line({byte}) *byte2line()*
Return the line number that contains the character at byte
@@ -579,8 +599,9 @@ byte2line({byte}) *byte2line()*
Returns -1 if the {byte} value is invalid.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetOffset()->byte2line()
+<
byteidx({expr}, {nr} [, {utf16}]) *byteidx()*
Return byte index of the {nr}th character in the String
@@ -599,10 +620,10 @@ byteidx({expr}, {nr} [, {utf16}]) *byteidx()*
middle of a character (e.g. in a 4-byte character), then the
byte index of the first byte in the character is returned.
Refer to |string-offset-encoding| for more information.
- Example : >
+ Example : >vim
echo matchstr(str, ".", byteidx(str, 3))
< will display the fourth character. Another way to do the
- same: >
+ same: >vim
let s = strpart(str, byteidx(str, 3))
echo strpart(s, 0, byteidx(s, 1))
< Also see |strgetchar()| and |strcharpart()|.
@@ -612,17 +633,18 @@ byteidx({expr}, {nr} [, {utf16}]) *byteidx()*
in bytes is returned.
See |charidx()| and |utf16idx()| for getting the character and
UTF-16 index respectively from the byte index.
- Examples: >
- echo byteidx('a😊😊', 2) returns 5
- echo byteidx('a😊😊', 2, 1) returns 1
- echo byteidx('a😊😊', 3, 1) returns 5
+ Examples: >vim
+ echo byteidx('a😊😊', 2) " returns 5
+ echo byteidx('a😊😊', 2, 1) " returns 1
+ echo byteidx('a😊😊', 3, 1) " returns 5
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->byteidx(idx)
+<
byteidxcomp({expr}, {nr} [, {utf16}]) *byteidxcomp()*
Like byteidx(), except that a composing character is counted
- as a separate character. Example: >
+ as a separate character. Example: >vim
let s = 'e' .. nr2char(0x301)
echo byteidx(s, 1)
echo byteidxcomp(s, 1)
@@ -631,8 +653,9 @@ byteidxcomp({expr}, {nr} [, {utf16}]) *byteidxcomp()*
character is 3 bytes), the second echo results in 1 ('e' is
one byte).
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->byteidxcomp(idx)
+<
call({func}, {arglist} [, {dict}]) *call()* *E699*
Call function {func} with the items in |List| {arglist} as
@@ -643,7 +666,7 @@ call({func}, {arglist} [, {dict}]) *call()* *E699*
{dict} is for functions with the "dict" attribute. It will be
used to set the local variable "self". |Dictionary-function|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFunc()->call([arg, arg], dict)
<
@@ -651,17 +674,17 @@ ceil({expr}) *ceil()*
Return the smallest integral value greater than or equal to
{expr} as a |Float| (round up).
{expr} must evaluate to a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo ceil(1.456)
-< 2.0 >
+< 2.0 >vim
echo ceil(-5.456)
-< -5.0 >
+< -5.0 >vim
echo ceil(4.0)
< 4.0
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->ceil()
<
@@ -694,8 +717,8 @@ chansend({id}, {data}) *chansend()*
{data} may be a string, string convertible, |Blob|, or a list.
If {data} is a list, the items will be joined by newlines; any
newlines in an item will be sent as NUL. To send a final
- newline, include a final empty string. Example: >
- :call chansend(id, ["abc", "123\n456", ""])
+ newline, include a final empty string. Example: >vim
+ call chansend(id, ["abc", "123\n456", ""])
< will send "abc<NL>123<NUL>456<NL>".
chansend() writes raw data, not RPC messages. If the channel
@@ -704,12 +727,12 @@ chansend({id}, {data}) *chansend()*
char2nr({string} [, {utf8}]) *char2nr()*
Return Number value of the first char in {string}.
- Examples: >
- char2nr(" ") returns 32
- char2nr("ABC") returns 65
- char2nr("Γ‘") returns 225
- char2nr("Γ‘"[0]) returns 195
- char2nr("\<M-x>") returns 128
+ Examples: >vim
+ echo char2nr(" ") " returns 32
+ echo char2nr("ABC") " returns 65
+ echo char2nr("Γ‘") " returns 225
+ echo char2nr("Γ‘"[0]) " returns 195
+ echo char2nr("\<M-x>") " returns 128
< Non-ASCII characters are always treated as UTF-8 characters.
{utf8} is ignored, it exists only for backwards-compatibility.
A combining character is a separate character.
@@ -717,8 +740,9 @@ char2nr({string} [, {utf8}]) *char2nr()*
Returns 0 if {string} is not a |String|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetChar()->char2nr()
+<
charclass({string}) *charclass()*
Return the character class of the first character in {string}.
@@ -736,11 +760,11 @@ charcol({expr} [, {winid}]) *charcol()*
position given with {expr} instead of the byte position.
Example:
- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >
- charcol('.') returns 3
- col('.') returns 7
+ With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >vim
+ echo charcol('.') " returns 3
+ echo col('.') " returns 7
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetPos()->col()
<
@@ -771,14 +795,15 @@ charidx({string}, {idx} [, {countcc} [, {utf16}]]) *charidx()*
from the character index and |utf16idx()| for getting the
UTF-16 index from the character index.
Refer to |string-offset-encoding| for more information.
- Examples: >
- echo charidx('áb́ć', 3) returns 1
- echo charidx('áb́ć', 6, 1) returns 4
- echo charidx('áb́ć', 16) returns -1
- echo charidx('a😊😊', 4, 0, 1) returns 2
+ Examples: >vim
+ echo charidx('áb́ć', 3) " returns 1
+ echo charidx('áb́ć', 6, 1) " returns 4
+ echo charidx('áb́ć', 16) " returns -1
+ echo charidx('a😊😊', 4, 0, 1) " returns 2
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->charidx(idx)
+<
chdir({dir}) *chdir()*
Change the current working directory to {dir}. The scope of
@@ -795,14 +820,14 @@ chdir({dir}) *chdir()*
this to another chdir() to restore the directory.
On failure, returns an empty string.
- Example: >
+ Example: >vim
let save_dir = chdir(newdir)
if save_dir != ""
" ... do some work
call chdir(save_dir)
endif
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetDir()->chdir()
<
@@ -814,8 +839,9 @@ cindent({lnum}) *cindent()*
When {lnum} is invalid -1 is returned.
See |C-indenting|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->cindent()
+<
clearmatches([{win}]) *clearmatches()*
Clears all matches previously defined for the current window
@@ -823,7 +849,7 @@ clearmatches([{win}]) *clearmatches()*
If {win} is specified, use the window with this number or
window ID instead of the current window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWin()->clearmatches()
<
@@ -850,11 +876,11 @@ col({expr} [, {winid}]) *col()*
For the screen column position use |virtcol()|. For the
character position use |charcol()|.
Note that only marks in the current file can be used.
- Examples: >
- col(".") column of cursor
- col("$") length of cursor line plus one
- col("'t") column of mark t
- col("'" .. markname) column of mark markname
+ Examples: >vim
+ echo col(".") " column of cursor
+ echo col("$") " length of cursor line plus one
+ echo col("'t") " column of mark t
+ echo col("'" .. markname) " column of mark markname
< The first column is 1. Returns 0 if {expr} is invalid or when
the window with ID {winid} is not found.
For an uppercase mark the column may actually be in another
@@ -862,10 +888,10 @@ col({expr} [, {winid}]) *col()*
For the cursor position, when 'virtualedit' is active, the
column is one higher if the cursor is after the end of the
line. Also, when using a <Cmd> mapping the cursor isn't
- moved, this can be used to obtain the column in Insert mode: >
- :imap <F2> <Cmd>echo col(".").."\n"<CR>
+ moved, this can be used to obtain the column in Insert mode: >vim
+ imap <F2> <Cmd>echo col(".").."\n"<CR>
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetPos()->col()
<
@@ -887,7 +913,7 @@ complete({startcol}, {matches}) *complete()* *E785*
The match can be selected with CTRL-N and CTRL-P as usual with
Insert mode completion. The popup menu will appear if
specified, see |ins-completion-menu|.
- Example: >
+ Example: >vim
inoremap <F5> <C-R>=ListMonths()<CR>
func ListMonths()
@@ -900,8 +926,9 @@ complete({startcol}, {matches}) *complete()* *E785*
an empty string is returned to avoid a zero being inserted.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetMatches()->complete(col('.'))
+<
complete_add({expr}) *complete_add()*
Add {expr} to the list of matches. Only to be used by the
@@ -912,8 +939,9 @@ complete_add({expr}) *complete_add()*
See |complete-functions| for an explanation of {expr}. It is
the same as one item in the list that 'omnifunc' would return.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMoreMatches()->complete_add()
+<
complete_check() *complete_check()*
Check for a key typed while looking for completion matches.
@@ -973,7 +1001,7 @@ complete_info([{what}]) *complete_info()*
Returns an empty |Dictionary| on error.
- Examples: >
+ Examples: >vim
" Get all items
call complete_info()
" Get only 'mode'
@@ -981,7 +1009,7 @@ complete_info([{what}]) *complete_info()*
" Get only 'mode' and 'pum_visible'
call complete_info(['mode', 'pum_visible'])
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetItems()->complete_info()
<
@@ -997,11 +1025,11 @@ confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()*
some systems the string is wrapped when it doesn't fit.
{choices} is a String, with the individual choices separated
- by '\n', e.g. >
+ by '\n', e.g. >vim
confirm("Save changes?", "&Yes\n&No\n&Cancel")
< The letter after the '&' is the shortcut key for that choice.
Thus you can type 'c' to select "Cancel". The shortcut does
- not need to be the first letter: >
+ not need to be the first letter: >vim
confirm("file has been modified", "&Save\nSave &All")
< For the console, the first letter of each choice is used as
the default shortcut key. Case is ignored.
@@ -1020,7 +1048,7 @@ confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()*
If the user aborts the dialog by pressing <Esc>, CTRL-C,
or another valid interrupt key, confirm() returns 0.
- An example: >
+ An example: >vim
let choice = confirm("What do you want?",
\ "&Apples\n&Oranges\n&Bananas", 2)
if choice == 0
@@ -1037,7 +1065,7 @@ confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()*
don't fit, a vertical layout is used anyway. For some systems
the horizontal layout is always used.
- Can also be used as a |method|in: >
+ Can also be used as a |method|in: >vim
BuildMessage()->confirm("&Yes\n&No")
<
@@ -1050,35 +1078,38 @@ copy({expr}) *copy()*
changing an item changes the contents of both |Lists|.
A |Dictionary| is copied in a similar way as a |List|.
Also see |deepcopy()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->copy()
+<
cos({expr}) *cos()*
Return the cosine of {expr}, measured in radians, as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo cos(100)
-< 0.862319 >
- :echo cos(-4.01)
+ Examples: >vim
+ echo cos(100)
+< 0.862319 >vim
+ echo cos(-4.01)
< -0.646043
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->cos()
+<
cosh({expr}) *cosh()*
Return the hyperbolic cosine of {expr} as a |Float| in the range
[1, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo cosh(0.5)
-< 1.127626 >
- :echo cosh(-0.5)
+ Examples: >vim
+ echo cosh(0.5)
+< 1.127626 >vim
+ echo cosh(-0.5)
< -1.127626
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->cosh()
+<
count({comp}, {expr} [, {ic} [, {start}]]) *count()*
Return the number of times an item with value {expr} appears
@@ -1093,7 +1124,7 @@ count({comp}, {expr} [, {ic} [, {start}]]) *count()*
occurrences of {expr} is returned. Zero is returned when
{expr} is an empty string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->count(val)
<
@@ -1155,8 +1186,9 @@ cursor({list}) *cursor()*
position within a <Tab> or after the last character.
Returns 0 when the position could be set, -1 otherwise.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCursorPos()->cursor()
+<
debugbreak({pid}) *debugbreak()*
Specifically used to interrupt a program being debugged. It
@@ -1167,7 +1199,7 @@ debugbreak({pid}) *debugbreak()*
Returns |TRUE| if successfully interrupted the program.
Otherwise returns |FALSE|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPid()->debugbreak()
<
@@ -1191,8 +1223,9 @@ deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
{noref} set to 1 will fail.
Also see |copy()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetObject()->deepcopy()
+<
delete({fname} [, {flags}]) *delete()*
Without {flags} or with {flags} empty: Deletes the file by the
@@ -1213,8 +1246,9 @@ delete({fname} [, {flags}]) *delete()*
operation was successful and -1/true when the deletion failed
or partly failed.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->delete()
+<
deletebufline({buf}, {first} [, {last}]) *deletebufline()*
Delete lines {first} to {last} (inclusive) from buffer {buf}.
@@ -1230,7 +1264,7 @@ deletebufline({buf}, {first} [, {last}]) *deletebufline()*
when using |line()| this refers to the current buffer. Use "$"
to refer to the last line in buffer {buf}.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->deletebufline(1)
<
@@ -1245,7 +1279,7 @@ dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
After this is called, every change on {dict} and on keys
matching {pattern} will result in {callback} being invoked.
- For example, to watch all global variables: >
+ For example, to watch all global variables: >vim
silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
function! OnDictChanged(d,k,z)
echomsg string(a:k) string(a:z)
@@ -1300,8 +1334,9 @@ diff_filler({lnum}) *diff_filler()*
line, "'m" mark m, etc.
Returns 0 if the current window is not in diff mode.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->diff_filler()
+<
diff_hlID({lnum}, {col}) *diff_hlID()*
Returns the highlight ID for diff mode at line {lnum} column
@@ -1314,7 +1349,7 @@ diff_hlID({lnum}, {col}) *diff_hlID()*
The highlight ID can be used with |synIDattr()| to obtain
syntax information about the highlighting.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->diff_hlID(col)
<
@@ -1326,15 +1361,15 @@ digraph_get({chars}) *digraph_get()* *E1214*
Also see |digraph_getlist()|.
- Examples: >
+ Examples: >vim
" Get a built-in digraph
- :echo digraph_get('00') " Returns '∞'
+ echo digraph_get('00') " Returns '∞'
" Get a user-defined digraph
- :call digraph_set('aa', 'あ')
- :echo digraph_get('aa') " Returns 'あ'
+ call digraph_set('aa', 'あ')
+ echo digraph_get('aa') " Returns 'あ'
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetChars()->digraph_get()
<
@@ -1345,14 +1380,14 @@ digraph_getlist([{listall}]) *digraph_getlist()*
Also see |digraph_get()|.
- Examples: >
+ Examples: >vim
" Get user-defined digraphs
- :echo digraph_getlist()
+ echo digraph_getlist()
" Get all the digraphs, including default digraphs
- :echo digraph_getlist(1)
+ echo digraph_getlist(1)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetNumber()->digraph_getlist()
<
@@ -1370,10 +1405,10 @@ digraph_set({chars}, {digraph}) *digraph_set()*
If you want to define multiple digraphs at once, you can use
|digraph_setlist()|.
- Example: >
+ Example: >vim
call digraph_set(' ', 'あ')
<
- Can be used as a |method|: >
+ Can be used as a |method|: >vim
GetString()->digraph_set('あ')
<
@@ -1382,17 +1417,17 @@ digraph_setlist({digraphlist}) *digraph_setlist()*
digraphs at once. {digraphlist} is a list composed of lists,
where each list contains two strings with {chars} and
{digraph} as in |digraph_set()|. *E1216*
- Example: >
+ Example: >vim
call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
<
- It is similar to the following: >
+ It is similar to the following: >vim
for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
call digraph_set(chars, digraph)
endfor
< Except that the function returns after the first error,
following digraphs will not be added.
- Can be used as a |method|: >
+ Can be used as a |method|: >vim
GetList()->digraph_setlist()
<
@@ -1405,26 +1440,28 @@ empty({expr}) *empty()*
- |v:false| and |v:null| are empty, |v:true| is not.
- A |Blob| is empty when its length is zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->empty()
+<
environ() *environ()*
Return all of environment variables as dictionary. You can
- check if an environment variable exists like this: >
- :echo has_key(environ(), 'HOME')
+ check if an environment variable exists like this: >vim
+ echo has_key(environ(), 'HOME')
< Note that the variable name may be CamelCase; to ignore case
- use this: >
- :echo index(keys(environ()), 'HOME', 0, 1) != -1
+ use this: >vim
+ echo index(keys(environ()), 'HOME', 0, 1) != -1
+<
escape({string}, {chars}) *escape()*
Escape the characters in {chars} that occur in {string} with a
- backslash. Example: >
- :echo escape('c:\program files\vim', ' \')
+ backslash. Example: >vim
+ echo escape('c:\program files\vim', ' \')
< results in: >
c:\\program\ files\\vim
< Also see |shellescape()| and |fnameescape()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->escape(' \')
<
@@ -1435,8 +1472,9 @@ eval({string}) *eval()*
of them. Also works for |Funcref|s that refer to existing
functions.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
argv->join()->eval()
+<
eventhandler() *eventhandler()*
Returns 1 when inside an event handler. That is that Vim got
@@ -1467,17 +1505,18 @@ executable({expr}) *executable()*
-1 not implemented on this system
|exepath()| can be used to get the full path of an executable.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->executable()
+<
execute({command} [, {silent}]) *execute()*
Execute {command} and capture its output.
If {command} is a |String|, returns {command} output.
If {command} is a |List|, returns concatenated outputs.
Line continuations in {command} are not recognized.
- Examples: >
+ Examples: >vim
echo execute('echon "foo"')
-< foo >
+< foo >vim
echo execute(['echon "foo"', 'echon "bar"'])
< foobar
@@ -1488,7 +1527,7 @@ execute({command} [, {silent}]) *execute()*
The default is "silent". Note that with "silent!", unlike
`:redir`, error messages are dropped.
- To get a list of lines use `split()` on the result: >
+ To get a list of lines use `split()` on the result: >vim
execute('args')->split("\n")
< This function is not available in the |sandbox|.
@@ -1498,8 +1537,9 @@ execute({command} [, {silent}]) *execute()*
To execute a command in another window than the current one
use `win_execute()`.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->execute()
+<
exepath({expr}) *exepath()*
Returns the full path of {expr} if it is an executable and
@@ -1507,7 +1547,7 @@ exepath({expr}) *exepath()*
Returns empty string otherwise.
If {expr} starts with "./" the |current-directory| is used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->exepath()
<
@@ -1525,11 +1565,11 @@ exists({expr}) *exists()*
entries, |List| items, etc.
Beware that evaluating an index may
cause an error message for an invalid
- expression. E.g.: >
- :let l = [1, 2, 3]
- :echo exists("l[5]")
-< 0 >
- :echo exists("l[xx]")
+ 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,
@@ -1569,52 +1609,54 @@ exists({expr}) *exists()*
##event autocommand for this event is
supported.
- Examples: >
- exists("&mouse")
- exists("$HOSTNAME")
- exists("*strftime")
- exists("*s:MyFunc")
- exists("*MyFunc")
- exists("bufcount")
- exists(":Make")
- exists("#CursorHold")
- exists("#BufReadPre#*.gz")
- exists("#filetypeindent")
- exists("#filetypeindent#FileType")
- exists("#filetypeindent#FileType#*")
- exists("##ColorScheme")
+ Examples: >vim
+ echo exists("&mouse")
+ echo exists("$HOSTNAME")
+ echo exists("*strftime")
+ echo exists("*s:MyFunc")
+ echo exists("*MyFunc")
+ 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: >
- exists(":make")
- <NOT working example: >
- exists(":make install")
+ 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: >
- exists(bufcount)
+ 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.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Varname()->exists()
+<
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: >
- :echo exp(2)
-< 7.389056 >
- :echo exp(-1)
+ Examples: >vim
+ echo exp(2)
+< 7.389056 >vim
+ echo exp(-1)
< 0.367879
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->exp()
+<
expand({string} [, {nosuf} [, {list}]]) *expand()*
Expand wildcards and the following special keywords in
@@ -1661,18 +1703,18 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
:r root (one extension removed)
:e extension only
- Example: >
- :let &tags = expand("%:p:h") .. "/tags"
+ Example: >vim
+ let &tags = expand("%:p:h") .. "/tags"
< Note that when expanding a string that starts with '%', '#' or
- '<', any following text is ignored. This does NOT work: >
- :let doesntwork = expand("%:h.bak")
-< Use this: >
- :let doeswork = expand("%:h") .. ".bak"
+ '<', any following text is ignored. This does NOT work: >vim
+ let doesntwork = expand("%:h.bak")
+< Use this: >vim
+ let doeswork = expand("%:h") .. ".bak"
< Also note that expanding "<cfile>" and others only returns the
referenced file name without further expansion. If "<cfile>"
is "~/.cshrc", you need to do another expand() to have the
- "~/" expanded into the path of the home directory: >
- :echo expand(expand("<cfile>"))
+ "~/" expanded into the path of the home directory: >vim
+ echo expand(expand("<cfile>"))
<
There cannot be white space between the variables and the
following modifier. The |fnamemodify()| function can be used
@@ -1692,8 +1734,8 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
{nosuf} argument is given and it is |TRUE|.
Names for non-existing files are included. The "**" item can
be used to search in a directory tree. For example, to find
- all "README" files in the current directory and below: >
- :echo expand("**/README")
+ all "README" files in the current directory and below: >vim
+ echo expand("**/README")
<
expand() can also be used to expand variables and environment
variables that are only known in a shell. But this can be
@@ -1707,8 +1749,9 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
See |glob()| for finding existing files. See |system()| for
getting the raw output of an external command.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Getpattern()->expand()
+<
expandcmd({string} [, {options}]) *expandcmd()*
Expand special items in String {string} like what is done for
@@ -1726,12 +1769,14 @@ expandcmd({string} [, {options}]) *expandcmd()*
Returns the expanded string. If an error is encountered
during expansion, the unmodified {string} is returned.
- Example: >
- :echo expandcmd('make %<.o')
+ Example: >vim
+ echo expandcmd('make %<.o')
+< >
make /path/runtime/doc/builtin.o
- :echo expandcmd('make %<.o', {'errmsg': v:true})
+< >vim
+ echo expandcmd('make %<.o', {'errmsg': v:true})
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->expandcmd()
<
@@ -1744,16 +1789,16 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()*
item with index {expr3} in {expr1}. When {expr3} is zero
insert before the first item. When {expr3} is equal to
len({expr1}) then {expr2} is appended.
- Examples: >
- :echo sort(extend(mylist, [7, 5]))
- :call extend(mylist, [2, 3], 1)
+ Examples: >vim
+ echo sort(extend(mylist, [7, 5]))
+ call extend(mylist, [2, 3], 1)
< When {expr1} is the same List as {expr2} then the number of
items copied is equal to the original length of the List.
E.g., when {expr3} is 1 you get N new copies of the first item
(where N is the original length of the List).
Use |add()| to concatenate one item to a list. To concatenate
- two lists into a new list use the + operator: >
- :let newlist = [1, 2, 3] + [4, 5]
+ two lists into a new list use the + operator: >vim
+ let newlist = [1, 2, 3] + [4, 5]
<
If they are |Dictionaries|:
Add all entries from {expr2} to {expr1}.
@@ -1771,7 +1816,7 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()*
fails.
Returns {expr1}. Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->extend(otherlist)
<
@@ -1825,8 +1870,9 @@ feedkeys({string} [, {mode}]) *feedkeys()*
Return value is always 0.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetInput()->feedkeys()
+<
filereadable({file}) *filereadable()*
The result is a Number, which is |TRUE| when a file with the
@@ -1835,14 +1881,19 @@ filereadable({file}) *filereadable()*
expression, which is used as a String.
If you don't care about the file being readable you can use
|glob()|.
- {file} is used as-is, you may want to expand wildcards first: >
+ {file} is used as-is, you may want to expand wildcards first: >vim
echo filereadable('~/.vimrc')
+< >
0
+< >vim
echo filereadable(expand('~/.vimrc'))
+< >
1
+<
-< Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->filereadable()
+<
filewritable({file}) *filewritable()*
The result is a Number, which is 1 when a file with the
@@ -1850,8 +1901,9 @@ filewritable({file}) *filewritable()*
exist, or is not writable, the result is 0. If {file} is a
directory, and we can write to it, the result is 2.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->filewritable()
+<
filter({expr1}, {expr2}) *filter()*
{expr1} must be a |List|, |Blob|, or a |Dictionary|.
@@ -1867,11 +1919,11 @@ filter({expr1}, {expr2}) *filter()*
the current item. For a |Blob| |v:key| has the index of the
current byte.
- Examples: >
+ Examples: >vim
call filter(mylist, 'v:val !~ "OLD"')
-< Removes the items where "OLD" appears. >
+< Removes the items where "OLD" appears. >vim
call filter(mydict, 'v:key >= 8')
-< Removes the items with a key below 8. >
+< Removes the items with a key below 8. >vim
call filter(var, 0)
< Removes all the items, thus clears the |List| or |Dictionary|.
@@ -1883,19 +1935,19 @@ filter({expr1}, {expr2}) *filter()*
1. the key or the index of the current item.
2. the value of the current item.
The function must return |TRUE| if the item should be kept.
- Example that keeps the odd items of a list: >
+ Example that keeps the odd items of a list: >vim
func Odd(idx, val)
return a:idx % 2 == 1
endfunc
call filter(mylist, function('Odd'))
-< It is shorter when using a |lambda|: >
+< It is shorter when using a |lambda|: >vim
call filter(myList, {idx, val -> idx * val <= 42})
-< If you do not use "val" you can leave it out: >
+< If you do not use "val" you can leave it out: >vim
call filter(myList, {idx -> idx % 2 == 1})
<
The operation is done in-place. If you want a |List| or
- |Dictionary| to remain unmodified make a copy first: >
- :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
+ |Dictionary| to remain unmodified make a copy first: >vim
+ let l = filter(copy(mylist), 'v:val =~ "KEEP"')
< Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
filtered. When an error is encountered while evaluating
@@ -1903,8 +1955,9 @@ filter({expr1}, {expr2}) *filter()*
{expr2} is a Funcref errors inside a function are ignored,
unless it was defined with the "abort" flag.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->filter(expr2)
+<
finddir({name} [, {path} [, {count}]]) *finddir()*
Find directory {name} in {path}. Supports both downwards and
@@ -1924,19 +1977,21 @@ finddir({name} [, {path} [, {count}]]) *finddir()*
This is quite similar to the ex-command `:find`.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->finddir()
+<
findfile({name} [, {path} [, {count}]]) *findfile()*
Just like |finddir()|, but find a file instead of a directory.
Uses 'suffixesadd'.
- Example: >
- :echo findfile("tags.vim", ".;")
+ Example: >vim
+ echo findfile("tags.vim", ".;")
< Searches from the directory of the current file upwards until
it finds the file "tags.vim".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->findfile()
+<
flatten({list} [, {maxdepth}]) *flatten()*
Flatten {list} up to {maxdepth} levels. Without {maxdepth}
@@ -1951,13 +2006,13 @@ flatten({list} [, {maxdepth}]) *flatten()*
If there is an error the number zero is returned.
- Example: >
- :echo flatten([1, [2, [3, 4]], 5])
-< [1, 2, 3, 4, 5] >
- :echo flatten([1, [2, [3, 4]], 5], 1)
+ Example: >vim
+ echo flatten([1, [2, [3, 4]], 5])
+< [1, 2, 3, 4, 5] >vim
+ echo flatten([1, [2, [3, 4]], 5], 1)
< [1, 2, [3, 4], 5]
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->flatten()
<
@@ -1974,36 +2029,38 @@ float2nr({expr}) *float2nr()*
64-bit Number support is enabled, 0x7fffffffffffffff or
-0x7fffffffffffffff). NaN results in -0x80000000 (or when
64-bit Number support is enabled, -0x8000000000000000).
- Examples: >
+ Examples: >vim
echo float2nr(3.95)
-< 3 >
+< 3 >vim
echo float2nr(-23.45)
-< -23 >
+< -23 >vim
echo float2nr(1.0e100)
-< 2147483647 (or 9223372036854775807) >
+< 2147483647 (or 9223372036854775807) >vim
echo float2nr(-1.0e150)
-< -2147483647 (or -9223372036854775807) >
+< -2147483647 (or -9223372036854775807) >vim
echo float2nr(1.0e-100)
< 0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->float2nr()
+<
floor({expr}) *floor()*
Return the largest integral value less than or equal to
{expr} as a |Float| (round down).
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo floor(1.856)
-< 1.0 >
+< 1.0 >vim
echo floor(-5.456)
-< -6.0 >
+< -6.0 >vim
echo floor(4.0)
< 4.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->floor()
+<
fmod({expr1}, {expr2}) *fmod()*
Return the remainder of {expr1} / {expr2}, even if the
@@ -2015,18 +2072,19 @@ fmod({expr1}, {expr2}) *fmod()*
{expr1} and {expr2} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
|Number|.
- Examples: >
- :echo fmod(12.33, 1.22)
-< 0.13 >
- :echo fmod(-12.33, 1.22)
+ Examples: >vim
+ echo fmod(12.33, 1.22)
+< 0.13 >vim
+ echo fmod(-12.33, 1.22)
< -0.13
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->fmod(1.22)
+<
fnameescape({string}) *fnameescape()*
Escape {string} for use as file name command argument. All
- characters that have a special meaning, such as '%' and '|'
+ characters that have a special meaning, such as `'%'` and `'|'`
are escaped with a backslash.
For most systems the characters escaped are
" \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
@@ -2034,21 +2092,22 @@ fnameescape({string}) *fnameescape()*
A leading '+' and '>' is also escaped (special after |:edit|
and |:write|). And a "-" by itself (special after |:cd|).
Returns an empty string on error.
- Example: >
- :let fname = '+some str%nge|name'
- :exe "edit " .. fnameescape(fname)
-< results in executing: >
+ Example: >vim
+ let fname = '+some str%nge|name'
+ exe "edit " .. fnameescape(fname)
+< results in executing: >vim
edit \+some\ str\%nge\|name
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->fnameescape()
+<
fnamemodify({fname}, {mods}) *fnamemodify()*
Modify file name {fname} according to {mods}. {mods} is a
string of characters like it is used for file names on the
command line. See |filename-modifiers|.
- Example: >
- :echo fnamemodify("main.c", ":p:h")
+ Example: >vim
+ echo fnamemodify("main.c", ":p:h")
< results in: >
/home/user/vim/vim/src
< If {mods} is empty or an unsupported modifier is used then
@@ -2060,8 +2119,9 @@ fnamemodify({fname}, {mods}) *fnamemodify()*
Note: Environment variables don't work in {fname}, use
|expand()| first then.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->fnamemodify(':p:h')
+<
foldclosed({lnum}) *foldclosed()*
The result is a Number. If the line {lnum} is in a closed
@@ -2070,8 +2130,9 @@ foldclosed({lnum}) *foldclosed()*
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldclosed()
+<
foldclosedend({lnum}) *foldclosedend()*
The result is a Number. If the line {lnum} is in a closed
@@ -2080,8 +2141,9 @@ foldclosedend({lnum}) *foldclosedend()*
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldclosedend()
+<
foldlevel({lnum}) *foldlevel()*
The result is a Number, which is the foldlevel of line {lnum}
@@ -2095,7 +2157,7 @@ foldlevel({lnum}) *foldlevel()*
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldlevel()
<
@@ -2125,7 +2187,7 @@ foldtextresult({lnum}) *foldtextresult()*
line, "'m" mark m, etc.
Useful when exporting folded text, e.g., to HTML.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldtextresult()
<
@@ -2141,7 +2203,7 @@ fullcommand({name}) *fullcommand()*
For example `fullcommand('s')`, `fullcommand('sub')`,
`fullcommand(':%substitute')` all return "substitute".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->fullcommand()
<
@@ -2157,7 +2219,7 @@ funcref({name} [, {arglist}] [, {dict}]) *funcref()*
instead). {name} cannot be a builtin function.
Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFuncname()->funcref([arg])
<
@@ -2168,7 +2230,7 @@ function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* *E923*
{name} can also be a Funcref or a partial. When it is a
partial the dict stored in it will be used and the {dict}
- argument is not allowed. E.g.: >
+ argument is not allowed. E.g.: >vim
let FuncWithArg = function(dict.Func, [arg])
let Broken = function(dict.Func, [arg], dict)
<
@@ -2181,38 +2243,41 @@ function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* *E923*
the Funcref and will be used when the Funcref is called.
The arguments are passed to the function in front of other
- arguments, but after any argument from |method|. Example: >
+ arguments, but after any argument from |method|. Example: >vim
func Callback(arg1, arg2, name)
"...
+ endfunc
let Partial = function('Callback', ['one', 'two'])
"...
call Partial('name')
-< Invokes the function as with: >
+< Invokes the function as with: >vim
call Callback('one', 'two', 'name')
-< With a |method|: >
+< With a |method|: >vim
func Callback(one, two, three)
"...
+ endfunc
let Partial = function('Callback', ['two'])
"...
eval 'one'->Partial('three')
-< Invokes the function as with: >
+< Invokes the function as with: >vim
call Callback('one', 'two', 'three')
< The function() call can be nested to add more arguments to the
Funcref. The extra arguments are appended to the list of
- arguments. Example: >
+ arguments. Example: >vim
func Callback(arg1, arg2, name)
"...
+ endfunc
let Func = function('Callback', ['one'])
let Func2 = function(Func, ['two'])
"...
call Func2('name')
-< Invokes the function as with: >
+< Invokes the function as with: >vim
call Callback('one', 'two', 'name')
< The Dictionary is only useful when calling a "dict" function.
- In that case the {dict} is passed in as "self". Example: >
+ In that case the {dict} is passed in as "self". Example: >vim
function Callback() dict
echo "called for " .. self.name
endfunction
@@ -2223,24 +2288,26 @@ function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* *E923*
call Func() " will echo: called for example
< The use of function() is not needed when there are no extra
arguments, these two are equivalent, if Callback() is defined
- as context.Callback(): >
+ as context.Callback(): >vim
let Func = function('Callback', context)
let Func = context.Callback
-< The argument list and the Dictionary can be combined: >
+< The argument list and the Dictionary can be combined: >vim
function Callback(arg1, count) dict
"...
+ endfunction
let context = {"name": "example"}
let Func = function('Callback', ['one'], context)
"...
call Func(500)
-< Invokes the function as with: >
+< Invokes the function as with: >vim
call context.Callback('one', 500)
<
Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFuncname()->function([arg])
+<
garbagecollect([{atexit}]) *garbagecollect()*
Cleanup unused |Lists| and |Dictionaries| that have circular
@@ -2266,8 +2333,9 @@ get({list}, {idx} [, {default}]) *get()*
Get item {idx} from |List| {list}. When this item is not
available return {default}. Return zero when {default} is
omitted.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->get(idx)
+<
get({blob}, {idx} [, {default}])
Get byte {idx} from |Blob| {blob}. When this byte is not
@@ -2277,7 +2345,7 @@ get({blob}, {idx} [, {default}])
get({dict}, {key} [, {default}])
Get item with key {key} from |Dictionary| {dict}. When this
item is not available return {default}. Return zero when
- {default} is omitted. Useful example: >
+ {default} is omitted. Useful example: >vim
let val = get(g:, 'var_name', 'default')
< This gets the value of g:var_name if it exists, and uses
"default" when it does not exist.
@@ -2326,8 +2394,8 @@ getbufinfo([{dict}]) *getbufinfo()*
displayed in the window in the past.
If you want the line number of the
last known cursor position in a given
- window, use |line()|: >
- :echo line('.', {winid})
+ window, use |line()|: >vim
+ echo line('.', {winid})
<
linecount Number of lines in the buffer (only
valid when loaded)
@@ -2344,20 +2412,20 @@ getbufinfo([{dict}]) *getbufinfo()*
windows List of |window-ID|s that display this
buffer
- Examples: >
+ Examples: >vim
for buf in getbufinfo()
echo buf.name
endfor
for buf in getbufinfo({'buflisted':1})
if buf.changed
- ....
+ " ....
endif
endfor
<
- To get buffer-local options use: >
+ To get buffer-local options use: >vim
getbufvar({bufnr}, '&option_name')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->getbufinfo()
<
@@ -2383,10 +2451,10 @@ getbufline({buf}, {lnum} [, {end}]) *getbufline()*
This function works only for loaded buffers. For unloaded and
non-existing buffers, an empty |List| is returned.
- Example: >
- :let lines = getbufline(bufnr("myfile"), 1, "$")
+ Example: >vim
+ let lines = getbufline(bufnr("myfile"), 1, "$")
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetBufnr()->getbufline(lnum)
<
@@ -2411,11 +2479,11 @@ getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
For the use of {buf}, see |bufname()| above.
When the buffer or variable doesn't exist {def} or an empty
string is returned, there is no error message.
- Examples: >
- :let bufmodified = getbufvar(1, "&mod")
- :echo "todo myvar = " .. getbufvar("todo", "myvar")
+ Examples: >vim
+ let bufmodified = getbufvar(1, "&mod")
+ echo "todo myvar = " .. getbufvar("todo", "myvar")
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetBufnr()->getbufvar(varname)
<
@@ -2441,8 +2509,9 @@ getchangelist([{buf}]) *getchangelist()*
position refers to the position in the list. For other
buffers, it is set to the length of the list.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->getchangelist()
+<
getchar([expr]) *getchar()*
Get a single character from the user or input stream.
@@ -2478,7 +2547,7 @@ getchar([expr]) *getchar()*
|v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
|getmousepos()| can also be used. Mouse move events will be
ignored.
- This example positions the mouse as it would normally happen: >
+ This example positions the mouse as it would normally happen: >vim
let c = getchar()
if c == "\<LeftMouse>" && v:mouse_win > 0
exe v:mouse_win .. "wincmd w"
@@ -2493,20 +2562,20 @@ getchar([expr]) *getchar()*
There is no mapping for the character.
Key codes are replaced, thus when the user presses the <Del>
key you get the code for the <Del> key, not the raw character
- sequence. Examples: >
+ sequence. Examples: >vim
getchar() == "\<Del>"
getchar() == "\<S-Left>"
-< This example redefines "f" to ignore case: >
- :nmap f :call FindChar()<CR>
- :function FindChar()
- : let c = nr2char(getchar())
- : while col('.') < col('$') - 1
- : normal l
- : if getline('.')[col('.') - 1] ==? c
- : break
- : endif
- : endwhile
- :endfunction
+< This example redefines "f" to ignore case: >vim
+ nmap f :call FindChar()<CR>
+ function FindChar()
+ let c = nr2char(getchar())
+ while col('.') < col('$') - 1
+ normal l
+ if getline('.')[col('.') - 1] ==? c
+ break
+ endif
+ endwhile
+ endfunction
<
getcharmod() *getcharmod()*
@@ -2534,12 +2603,13 @@ getcharpos({expr}) *getcharpos()*
of the last character.
Example:
- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >
+ With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >vim
getcharpos('.') returns [0, 5, 3, 0]
getpos('.') returns [0, 5, 7, 0]
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMark()->getcharpos()
+<
getcharsearch() *getcharsearch()*
Return the current character search information as a {dict}
@@ -2556,9 +2626,9 @@ getcharsearch() *getcharsearch()*
This can be useful to always have |;| and |,| search
forward/backward regardless of the direction of the previous
- character search: >
- :nnoremap <expr> ; getcharsearch().forward ? ';' : ','
- :nnoremap <expr> , getcharsearch().forward ? ',' : ';'
+ character search: >vim
+ nnoremap <expr> ; getcharsearch().forward ? ';' : ','
+ nnoremap <expr> , getcharsearch().forward ? ',' : ';'
< Also see |setcharsearch()|.
getcharstr([expr]) *getcharstr()*
@@ -2586,8 +2656,8 @@ getcmdline() *getcmdline()*
Return the current command-line. Only works when the command
line is being edited, thus requires use of |c_CTRL-\_e| or
|c_CTRL-R_=|.
- Example: >
- :cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
+ Example: >vim
+ cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
< Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and
|setcmdline()|.
Returns an empty string when entering a password or using
@@ -2692,13 +2762,13 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
If {type} is "cmdline", then the |cmdline-completion| result is
returned. For example, to complete the possible values after
- a ":call" command: >
+ a ":call" command: >vim
echo getcompletion('call ', 'cmdline')
<
If there are no matches, an empty list is returned. An
invalid value for {type} produces an error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPattern()->getcompletion('color')
<
@@ -2720,14 +2790,14 @@ getcurpos([{winid}]) *getcurpos()*
current value of the buffer if it is not the current window.
If {winid} is invalid a list with zeroes is returned.
- This can be used to save and restore the cursor position: >
+ This can be used to save and restore the cursor position: >vim
let save_cursor = getcurpos()
MoveTheCursorAround
call setpos('.', save_cursor)
< Note that this only works within the window. See
|winrestview()| for restoring more state.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->getcurpos()
<
@@ -2736,12 +2806,13 @@ getcursorcharpos([{winid}]) *getcursorcharpos()*
List is a character index instead of a byte index.
Example:
- With the cursor on '보' in line 3 with text "μ—¬λ³΄μ„Έμš”": >
- getcursorcharpos() returns [0, 3, 2, 0, 3]
- getcurpos() returns [0, 3, 4, 0, 3]
+ With the cursor on '보' in line 3 with text "μ—¬λ³΄μ„Έμš”": >vim
+ getcursorcharpos() " returns [0, 3, 2, 0, 3]
+ getcurpos() " returns [0, 3, 4, 0, 3]
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->getcursorcharpos()
+<
getcwd([{winnr} [, {tabnr}]]) *getcwd()*
With no arguments, returns the name of the effective
@@ -2750,7 +2821,7 @@ getcwd([{winnr} [, {tabnr}]]) *getcwd()*
ignored.
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing tab number implies 0.
- Thus the following are equivalent: >
+ Thus the following are equivalent: >vim
getcwd(0)
getcwd(0, 0)
< If {winnr} is -1 it is ignored, only the tab is resolved.
@@ -2759,20 +2830,22 @@ getcwd([{winnr} [, {tabnr}]]) *getcwd()*
directory is returned.
Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->getcwd()
+<
getenv({name}) *getenv()*
Return the value of environment variable {name}. The {name}
- argument is a string, without a leading '$'. Example: >
+ argument is a string, without a leading '$'. Example: >vim
myHome = getenv('HOME')
< When the variable does not exist |v:null| is returned. That
is different from a variable set to an empty string.
See also |expr-env|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetVarname()->getenv()
+<
getfontname([{name}]) *getfontname()*
Without an argument returns the name of the normal font being
@@ -2795,13 +2868,13 @@ getfperm({fname}) *getfperm()*
"rwx" flags represent, in turn, the permissions of the owner
of the file, the group the file belongs to, and other users.
If a user does not have a given permission the flag for this
- is replaced with the string "-". Examples: >
- :echo getfperm("/etc/passwd")
- :echo getfperm(expand("~/.config/nvim/init.vim"))
+ is replaced with the string "-". Examples: >vim
+ echo getfperm("/etc/passwd")
+ echo getfperm(expand("~/.config/nvim/init.vim"))
< This will hopefully (from a security point of view) display
the string "rw-r--r--" or even "rw-------".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getfperm()
<
For setting permissions use |setfperm()|.
@@ -2814,8 +2887,9 @@ getfsize({fname}) *getfsize()*
If the size of {fname} is too big to fit in a Number then -2
is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getfsize()
+<
getftime({fname}) *getftime()*
The result is a Number, which is the last modification time of
@@ -2824,8 +2898,9 @@ getftime({fname}) *getftime()*
|localtime()| and |strftime()|.
If the file {fname} can't be found -1 is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getftime()
+<
getftype({fname}) *getftype()*
The result is a String, which is a description of the kind of
@@ -2841,14 +2916,15 @@ getftype({fname}) *getftype()*
Socket "socket"
FIFO "fifo"
All other "other"
- Example: >
+ Example: >vim
getftype("/home")
< Note that a type such as "link" will only be returned on
systems that support it. On some systems only "dir" and
"file" are returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getftype()
+<
getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
Returns the |jumplist| for the specified window.
@@ -2870,17 +2946,17 @@ getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
filename filename if available
lnum line number
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->getjumplist()
<
getline({lnum} [, {end}]) *getline()*
Without {end} the result is a String, which is line {lnum}
- from the current buffer. Example: >
+ from the current buffer. Example: >vim
getline(1)
< When {lnum} is a String that doesn't start with a
digit, |line()| is called to translate the String into a Number.
- To get the line under the cursor: >
+ To get the line under the cursor: >vim
getline(".")
< When {lnum} is a number smaller than 1 or bigger than the
number of lines in the buffer, an empty string is returned.
@@ -2891,12 +2967,12 @@ getline({lnum} [, {end}]) *getline()*
{end} is used in the same way as {lnum}.
Non-existing lines are silently omitted.
When {end} is before {lnum} an empty |List| is returned.
- Example: >
- :let start = line('.')
- :let end = search("^$") - 1
- :let lines = getline(start, end)
+ Example: >vim
+ let start = line('.')
+ let end = search("^$") - 1
+ let lines = getline(start, end)
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
ComputeLnum()->getline()
< To get lines from another buffer see |getbufline()| and
@@ -2929,9 +3005,9 @@ getloclist({nr} [, {what}]) *getloclist()*
location list for the window {nr}.
Returns an empty Dictionary if window {nr} does not exist.
- Examples (See also |getqflist-examples|): >
- :echo getloclist(3, {'all': 0})
- :echo getloclist(5, {'filewinid': 0})
+ Examples (See also |getqflist-examples|): >vim
+ echo getloclist(3, {'all': 0})
+ echo getloclist(5, {'filewinid': 0})
<
getmarklist([{buf}]) *getmarklist()*
@@ -2953,8 +3029,9 @@ getmarklist([{buf}]) *getmarklist()*
Refer to |getpos()| for getting information about a specific
mark.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->getmarklist()
+<
getmatches([{win}]) *getmatches()*
Returns a |List| with all matches previously defined for the
@@ -2966,26 +3043,26 @@ getmatches([{win}]) *getmatches()*
window ID instead of the current window. If {win} is invalid,
an empty list is returned.
Example: >vim
- :echo getmatches()
+ echo getmatches()
< >
[{"group": "MyGroup1", "pattern": "TODO",
"priority": 10, "id": 1}, {"group": "MyGroup2",
"pattern": "FIXME", "priority": 10, "id": 2}]
< >vim
- :let m = getmatches()
- :call clearmatches()
- :echo getmatches()
+ let m = getmatches()
+ call clearmatches()
+ echo getmatches()
< >
[]
< >vim
- :call setmatches(m)
- :echo getmatches()
+ call setmatches(m)
+ echo getmatches()
< >
[{"group": "MyGroup1", "pattern": "TODO",
"priority": 10, "id": 1}, {"group": "MyGroup2",
"pattern": "FIXME", "priority": 10, "id": 2}]
< >vim
- :unlet m
+ unlet m
<
getmousepos() *getmousepos()*
@@ -3044,14 +3121,15 @@ getpos({expr}) *getpos()*
A very large column number equal to |v:maxcol| can be returned,
in which case it means "after the end of the line".
If {expr} is invalid, returns a list with all zeros.
- This can be used to save and restore the position of a mark: >
+ This can be used to save and restore the position of a mark: >vim
let save_a_mark = getpos("'a")
- ...
+ " ...
call setpos("'a", save_a_mark)
< Also see |getcharpos()|, |getcurpos()| and |setpos()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMark()->getpos()
+<
getqflist([{what}]) *getqflist()*
Returns a |List| with all the current quickfix errors. Each
@@ -3079,11 +3157,11 @@ getqflist([{what}]) *getqflist()*
you may need to explicitly check for zero).
Useful application: Find pattern matches in multiple files and
- do something with them: >
- :vimgrep /theword/jg *.c
- :for d in getqflist()
- : echo bufname(d.bufnr) ':' d.lnum '=' d.text
- :endfor
+ do something with them: >vim
+ vimgrep /theword/jg *.c
+ for d in getqflist()
+ echo bufname(d.bufnr) ':' d.lnum '=' d.text
+ endfor
<
If the optional {what} dictionary argument is supplied, then
returns only the items listed in {what} as a dictionary. The
@@ -3148,16 +3226,16 @@ getqflist([{what}]) *getqflist()*
to "".
winid quickfix |window-ID|. If not present, set to 0
- Examples (See also |getqflist-examples|): >
- :echo getqflist({'all': 1})
- :echo getqflist({'nr': 2, 'title': 1})
- :echo getqflist({'lines' : ["F1:10:L10"]})
+ Examples (See also |getqflist-examples|): >vim
+ echo getqflist({'all': 1})
+ echo getqflist({'nr': 2, 'title': 1})
+ echo getqflist({'lines' : ["F1:10:L10"]})
<
getreg([{regname} [, 1 [, {list}]]]) *getreg()*
The result is a String, which is the contents of register
- {regname}. Example: >
- :let cliptext = getreg('*')
+ {regname}. Example: >vim
+ let cliptext = getreg('*')
< When register {regname} was not set the result is an empty
string.
The {regname} argument must be a string.
@@ -3177,8 +3255,9 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
If {regname} is not specified, |v:register| is used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRegname()->getreg()
+<
getreginfo([{regname}]) *getreginfo()*
Returns detailed information about register {regname} as a
@@ -3204,8 +3283,9 @@ getreginfo([{regname}]) *getreginfo()*
If {regname} is not specified, |v:register| is used.
The returned Dictionary can be passed to |setreg()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRegname()->getreginfo()
+<
getregtype([{regname}]) *getregtype()*
The result is a String, which is type of register {regname}.
@@ -3218,8 +3298,9 @@ getregtype([{regname}]) *getregtype()*
The {regname} argument is a string. If {regname} is not
specified, |v:register| is used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRegname()->getregtype()
+<
getscriptinfo([{opts}]) *getscriptinfo()*
Returns a |List| with information about all the sourced Vim
@@ -3253,9 +3334,9 @@ getscriptinfo([{opts}]) *getscriptinfo()*
this dictionary.
version Vimscript version, always 1
- Examples: >
- :echo getscriptinfo({'name': 'myscript'})
- :echo getscriptinfo({'sid': 15}).variables
+ Examples: >vim
+ echo getscriptinfo({'name': 'myscript'})
+ echo getscriptinfo({'sid': 15}).variables
<
gettabinfo([{tabnr}]) *gettabinfo()*
@@ -3271,8 +3352,9 @@ gettabinfo([{tabnr}]) *gettabinfo()*
tabpage-local variables
windows List of |window-ID|s in the tab page.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->gettabinfo()
+<
gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
Get the value of a tab-local variable {varname} in tab page
@@ -3284,8 +3366,9 @@ gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
When the tab or variable doesn't exist {def} or an empty
string is returned, there is no error message.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->gettabvar(varname)
+<
gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
Get the value of window-local variable {varname} in window
@@ -3306,15 +3389,16 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
or buffer-local variable.
When the tab, window or variable doesn't exist {def} or an
empty string is returned, there is no error message.
- Examples: >
- :let list_is_on = gettabwinvar(1, 2, '&list')
- :echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
+ Examples: >vim
+ let list_is_on = gettabwinvar(1, 2, '&list')
+ echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
<
- To obtain all window-local variables use: >
+ To obtain all window-local variables use: >vim
gettabwinvar({tabnr}, {winnr}, '&')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->gettabwinvar(winnr, varname)
+<
gettagstack([{winnr}]) *gettagstack()*
The result is a Dict, which is the tag stack of window {winnr}.
@@ -3344,7 +3428,7 @@ gettagstack([{winnr}]) *gettagstack()*
See |tagstack| for more information about the tag stack.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->gettagstack()
<
@@ -3393,8 +3477,9 @@ getwininfo([{winid}]) *getwininfo()*
winrow topmost screen line of the window;
"row" from |win_screenpos()|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->getwininfo()
+<
getwinpos([{timeout}]) *getwinpos()*
The result is a |List| with two numbers, the result of
@@ -3407,7 +3492,7 @@ getwinpos([{timeout}]) *getwinpos()*
When using a value less than 10 and no response is received
within that time, a previously reported position is returned,
if available. This can be used to poll for the position and
- do some work in the meantime: >
+ do some work in the meantime: >vim
while 1
let res = getwinpos(1)
if res[0] >= 0
@@ -3416,7 +3501,7 @@ getwinpos([{timeout}]) *getwinpos()*
" Do some work here
endwhile
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimeout()->getwinpos()
<
@@ -3434,11 +3519,11 @@ getwinposy() *getwinposy()*
getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
Like |gettabwinvar()| for the current tabpage.
- Examples: >
- :let list_is_on = getwinvar(2, '&list')
- :echo "myvar = " .. getwinvar(1, 'myvar')
+ Examples: >vim
+ let list_is_on = getwinvar(2, '&list')
+ echo "myvar = " .. getwinvar(1, 'myvar')
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetWinnr()->getwinvar(varname)
<
@@ -3469,38 +3554,43 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
|TRUE| then all symbolic links are included.
For most systems backticks can be used to get files names from
- any external command. Example: >
- :let tagfiles = glob("`find . -name tags -print`")
- :let &tags = substitute(tagfiles, "\n", ",", "g")
+ any external command. Example: >vim
+ let tagfiles = glob("`find . -name tags -print`")
+ let &tags = substitute(tagfiles, "\n", ",", "g")
< The result of the program inside the backticks should be one
item per line. Spaces inside an item are allowed.
See |expand()| for expanding special Vim variables. See
|system()| for getting the raw output of an external command.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->glob()
+<
glob2regpat({string}) *glob2regpat()*
Convert a file pattern, as used by glob(), into a search
pattern. The result can be used to match with a string that
- is a file name. E.g. >
+ is a file name. E.g. >vim
if filename =~ glob2regpat('Make*.mak')
-< This is equivalent to: >
+ " ...
+ endif
+< This is equivalent to: >vim
if filename =~ '^Make.*\.mak$'
+ " ...
+ endif
< When {string} is an empty string the result is "^$", match an
empty string.
Note that the result depends on the system. On MS-Windows
a backslash usually means a path separator.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->glob2regpat()
<
globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()*
Perform glob() for String {expr} on all directories in {path}
- and concatenate the results. Example: >
- :echo globpath(&rtp, "syntax/c.vim")
+ and concatenate the results. Example: >vim
+ echo globpath(&rtp, "syntax/c.vim")
<
{path} is a comma-separated list of directory names. Each
directory name is prepended to {expr} and expanded like with
@@ -3520,20 +3610,20 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()*
with all matching files. The advantage of using a List is, you
also get filenames containing newlines correctly. Otherwise
the result is a String and when there are several matches,
- they are separated by <NL> characters. Example: >
- :echo globpath(&rtp, "syntax/c.vim", 0, 1)
+ they are separated by <NL> characters. Example: >vim
+ echo globpath(&rtp, "syntax/c.vim", 0, 1)
<
{allinks} is used as with |glob()|.
The "**" item can be used to search in a directory tree.
For example, to find all "README.txt" files in the directories
- in 'runtimepath' and below: >
- :echo globpath(&rtp, "**/README.txt")
+ in 'runtimepath' and below: >vim
+ echo globpath(&rtp, "**/README.txt")
< Upwards search and limiting the depth of "**" is not
supported, thus using 'path' will not always work properly.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetExpr()->globpath(&rtp)
<
@@ -3547,9 +3637,9 @@ has({feature}) *has()*
< If the code has a syntax error then Vimscript may skip the
rest of the line. Put |:if| and |:endif| on separate lines to
- avoid the syntax error: >
+ avoid the syntax error: >vim
if has('feature')
- let x = this->breaks->without->the->feature
+ let x = this_breaks_without_the_feature()
endif
<
Vim's compile-time feature-names (prefixed with "+") are not
@@ -3558,12 +3648,16 @@ has({feature}) *has()*
Feature names can be:
1. Nvim version. For example the "nvim-0.2.1" feature means
- that Nvim is version 0.2.1 or later: >
- :if has("nvim-0.2.1")
+ that Nvim is version 0.2.1 or later: >vim
+ if has("nvim-0.2.1")
+ " ...
+ endif
< 2. Runtime condition or other pseudo-feature. For example the
- "win32" feature checks if the current system is Windows: >
- :if has("win32")
+ "win32" feature checks if the current system is Windows: >vim
+ if has("win32")
+ " ...
+ endif
< *feature-list*
List of supported pseudo-feature names:
acl |ACL| support.
@@ -3589,12 +3683,16 @@ has({feature}) *has()*
*has-patch*
3. Vim patch. For example the "patch123" feature means that
- Vim patch 123 at the current |v:version| was included: >
- :if v:version > 602 || v:version == 602 && has("patch148")
+ Vim patch 123 at the current |v:version| was included: >vim
+ if v:version > 602 || v:version == 602 && has("patch148")
+ " ...
+ endif
< 4. Vim version. For example the "patch-7.4.237" feature means
- that Nvim is Vim-compatible to version 7.4.237 or later. >
- :if has("patch-7.4.237")
+ that Nvim is Vim-compatible to version 7.4.237 or later. >vim
+ if has("patch-7.4.237")
+ " ...
+ endif
<
has_key({dict}, {key}) *has_key()*
@@ -3602,8 +3700,9 @@ has_key({dict}, {key}) *has_key()*
has an entry with key {key}. FALSE otherwise. The {key}
argument is a string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mydict->has_key(key)
+<
haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
The result is a Number, which is 1 when the window has set a
@@ -3612,18 +3711,19 @@ haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing argument implies 0.
- Thus the following are equivalent: >
- haslocaldir()
- haslocaldir(0)
- haslocaldir(0, 0)
+ Thus the following are equivalent: >vim
+ echo haslocaldir()
+ echo haslocaldir(0)
+ echo haslocaldir(0, 0)
< With {winnr} use that window in the current tabpage.
With {winnr} and {tabnr} use the window in that tabpage.
{winnr} can be the window number or the |window-ID|.
If {winnr} is -1 it is ignored, only the tab is resolved.
Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->haslocaldir()
+<
hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
The result is a Number, which is TRUE if there is a mapping
@@ -3649,15 +3749,16 @@ hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
When {mode} is omitted, "nvo" is used.
This function is useful to check if a mapping already exists
- to a function in a Vim script. Example: >
- :if !hasmapto('\ABCdoit')
- : map <Leader>d \ABCdoit
- :endif
+ to a function in a Vim script. Example: >vim
+ if !hasmapto('\ABCdoit')
+ map <Leader>d \ABCdoit
+ endif
< This installs the mapping to "\ABCdoit" only if there isn't
already a mapping to "\ABCdoit".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRHS()->hasmapto()
+<
histadd({history}, {item}) *histadd()*
Add the String {item} to the history {history} which can be
@@ -3675,14 +3776,15 @@ histadd({history}, {item}) *histadd()*
The result is a Number: TRUE if the operation was successful,
otherwise FALSE is returned.
- Example: >
- :call histadd("input", strftime("%Y %b %d"))
- :let date=input("Enter date: ")
+ Example: >vim
+ call histadd("input", strftime("%Y %b %d"))
+ let date=input("Enter date: ")
< This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetHistory()->histadd('search')
+<
histdel({history} [, {item}]) *histdel()*
Clear {history}, i.e. delete all its entries. See |hist-names|
@@ -3700,24 +3802,25 @@ histdel({history} [, {item}]) *histdel()*
is returned.
Examples:
- Clear expression register history: >
- :call histdel("expr")
+ Clear expression register history: >vim
+ call histdel("expr")
<
- Remove all entries starting with "*" from the search history: >
- :call histdel("/", '^\*')
+ Remove all entries starting with "*" from the search history: >vim
+ call histdel("/", '^\*')
<
- The following three are equivalent: >
- :call histdel("search", histnr("search"))
- :call histdel("search", -1)
- :call histdel("search", '^' .. histget("search", -1) .. '$')
+ The following three are equivalent: >vim
+ call histdel("search", histnr("search"))
+ call histdel("search", -1)
+ call histdel("search", '^' .. histget("search", -1) .. '$')
<
To delete the last search pattern and use the last-but-one for
- the "n" command and 'hlsearch': >
- :call histdel("search", -1)
- :let @/ = histget("search", -1)
+ the "n" command and 'hlsearch': >vim
+ call histdel("search", -1)
+ let @/ = histget("search", -1)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHistory()->histdel()
+<
histget({history} [, {index}]) *histget()*
The result is a String, the entry with Number {index} from
@@ -3727,25 +3830,26 @@ histget({history} [, {index}]) *histget()*
omitted, the most recent item from the history is used.
Examples:
- Redo the second last search from history. >
- :execute '/' .. histget("search", -2)
+ Redo the second last search from history. >vim
+ execute '/' .. histget("search", -2)
< Define an Ex command ":H {num}" that supports re-execution of
- the {num}th entry from the output of |:history|. >
- :command -nargs=1 H execute histget("cmd", 0+<args>)
+ the {num}th entry from the output of |:history|. >vim
+ command -nargs=1 H execute histget("cmd", 0+<args>)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHistory()->histget()
+<
histnr({history}) *histnr()*
The result is the Number of the current entry in {history}.
See |hist-names| for the possible values of {history}.
If an error occurred, -1 is returned.
- Example: >
- :let inp_index = histnr("expr")
+ Example: >vim
+ let inp_index = histnr("expr")
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetHistory()->histnr()
<
@@ -3755,11 +3859,12 @@ hlID({name}) *hlID()*
zero is returned.
This can be used to retrieve information about the highlight
group. For example, to get the background color of the
- "Comment" group: >
- :echo synIDattr(synIDtrans(hlID("Comment")), "bg")
+ "Comment" group: >vim
+ echo synIDattr(synIDtrans(hlID("Comment")), "bg")
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->hlID()
+<
hlexists({name}) *hlexists()*
The result is a Number, which is TRUE if a highlight group
@@ -3768,7 +3873,7 @@ hlexists({name}) *hlexists()*
been defined for it, it may also have been used for a syntax
item.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->hlexists()
<
@@ -3789,7 +3894,7 @@ iconv({string}, {from}, {to}) *iconv()*
from/to UCS-2 is automatically changed to use UTF-8. You
cannot use UCS-2 in a string anyway, because of the NUL bytes.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->iconv('latin1', 'utf-8')
<
@@ -3798,8 +3903,8 @@ id({expr}) *id()*
container type (|List|, |Dict|, |Blob| and |Partial|). It is
guaranteed that for the mentioned types `id(v1) ==# id(v2)`
returns true iff `type(v1) == type(v2) && v1 is v2`.
- Note that |v:_null_string|, |v:_null_list|, |v:_null_dict| and
- |v:_null_blob| have the same `id()` with different types
+ Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
+ `v:_null_blob` have the same `id()` with different types
because they are internally represented as NULL pointers.
`id()` returns a hexadecimal representanion of the pointers to
the containers (i.e. like `0x994a40`), same as `printf("%p",
@@ -3816,8 +3921,9 @@ indent({lnum}) *indent()*
|getline()|.
When {lnum} is invalid -1 is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->indent()
+<
index({object}, {expr} [, {start} [, {ic}]]) *index()*
Find {expr} in {object} and return its index. See
@@ -3840,12 +3946,15 @@ index({object}, {expr} [, {start} [, {ic}]]) *index()*
case must match.
-1 is returned when {expr} is not found in {object}.
- Example: >
- :let idx = index(words, "the")
- :if index(numbers, 123) >= 0
+ Example: >vim
+ let idx = index(words, "the")
+ if index(numbers, 123) >= 0
+ " ...
+ endif
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetObject()->index(what)
+<
indexof({object}, {expr} [, {opts}]) *indexof()*
Returns the index of an item in {object} where {expr} is
@@ -3879,14 +3988,15 @@ indexof({object}, {expr} [, {opts}]) *indexof()*
index; may be negative for an item relative to
the end
Returns -1 when {expr} evaluates to v:false for all the items.
- Example: >
- :let l = [#{n: 10}, #{n: 20}, #{n: 30}]
- :echo indexof(l, "v:val.n == 20")
- :echo indexof(l, {i, v -> v.n == 30})
- :echo indexof(l, "v:val.n == 20", #{startidx: 1})
+ Example: >vim
+ let l = [#{n: 10}, #{n: 20}, #{n: 30}]
+ echo indexof(l, "v:val.n == 20")
+ echo indexof(l, {i, v -> v.n == 30})
+ echo indexof(l, "v:val.n == 20", #{startidx: 1})
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
mylist->indexof(expr)
+<
input({prompt} [, {text} [, {completion}]]) *input()*
@@ -3911,22 +4021,22 @@ input({opts})
The input is entered just like a command-line, with the same
editing commands and mappings. There is a separate history
for lines typed for input().
- Example: >
- :if input("Coffee or beer? ") == "beer"
- : echo "Cheers!"
- :endif
+ Example: >vim
+ if input("Coffee or beer? ") == "beer"
+ echo "Cheers!"
+ endif
<
If the optional {text} argument is present and not empty, this
is used for the default reply, as if the user typed this.
- Example: >
- :let color = input("Color? ", "white")
+ Example: >vim
+ let color = input("Color? ", "white")
< The optional {completion} argument specifies the type of
completion supported for the input. Without it completion is
not performed. The supported completion types are the same as
that can be supplied to a user-defined command using the
"-complete=" argument. Refer to |:command-completion| for
- more information. Example: >
+ more information. Example: >vim
let fname = input("File: ", "", "file")
< *input()-highlight* *E5400* *E5402*
@@ -3947,7 +4057,7 @@ input({opts})
sections must be ordered so that next hl_start_col is greater
then or equal to previous hl_end_col.
- Example (try some input with parentheses): >
+ Example (try some input with parentheses): >vim
highlight RBP1 guibg=Red ctermbg=red
highlight RBP2 guibg=Yellow ctermbg=yellow
highlight RBP3 guibg=Green ctermbg=green
@@ -3992,16 +4102,17 @@ input({opts})
that further characters follow in the mapping, e.g., by using
|:execute| or |:normal|.
- Example with a mapping: >
- :nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
- :function GetFoo()
- : call inputsave()
- : let g:Foo = input("enter search pattern: ")
- : call inputrestore()
- :endfunction
+ Example with a mapping: >vim
+ nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
+ function GetFoo()
+ call inputsave()
+ let g:Foo = input("enter search pattern: ")
+ call inputrestore()
+ endfunction
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetPrompt()->input()
+<
inputlist({textlist}) *inputlist()*
{textlist} must be a |List| of strings. This |List| is
@@ -4016,12 +4127,13 @@ inputlist({textlist}) *inputlist()*
Make sure {textlist} has less than 'lines' entries, otherwise
it won't work. It's a good idea to put the entry number at
the start of the string. And put a prompt in the first item.
- Example: >
+ Example: >vim
let color = inputlist(['Select color:', '1. red',
\ '2. green', '3. blue'])
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetChoices()->inputlist()
+<
inputrestore() *inputrestore()*
Restore typeahead that was saved with a previous |inputsave()|.
@@ -4048,8 +4160,9 @@ inputsecret({prompt} [, {text}]) *inputsecret()*
typed on the command-line in response to the issued prompt.
NOTE: Command-line completion is not supported.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPrompt()->inputsecret()
+<
insert({object}, {item} [, {idx}]) *insert()*
When {object} is a |List| or a |Blob| insert {item} at the start
@@ -4060,36 +4173,39 @@ insert({object}, {item} [, {idx}]) *insert()*
like omitting {idx}. A negative {idx} is also possible, see
|list-index|. -1 inserts just before the last item.
- Returns the resulting |List| or |Blob|. Examples: >
- :let mylist = insert([2, 3, 5], 1)
- :call insert(mylist, 4, -1)
- :call insert(mylist, 6, len(mylist))
+ Returns the resulting |List| or |Blob|. Examples: >vim
+ let mylist = insert([2, 3, 5], 1)
+ call insert(mylist, 4, -1)
+ call insert(mylist, 6, len(mylist))
< The last example can be done simpler with |add()|.
Note that when {item} is a |List| it is inserted as a single
item. Use |extend()| to concatenate |Lists|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->insert(item)
+<
interrupt() *interrupt()*
Interrupt script execution. It works more or less like the
user typing CTRL-C, most commands won't execute and control
returns to the user. This is useful to abort execution
- from lower down, e.g. in an autocommand. Example: >
- :function s:check_typoname(file)
- : if fnamemodify(a:file, ':t') == '['
- : echomsg 'Maybe typo'
- : call interrupt()
- : endif
- :endfunction
- :au BufWritePre * call s:check_typoname(expand('<amatch>'))
+ from lower down, e.g. in an autocommand. Example: >vim
+ function s:check_typoname(file)
+ if fnamemodify(a:file, ':t') == '['
+ echomsg 'Maybe typo'
+ call interrupt()
+ endif
+ endfunction
+ au BufWritePre * call s:check_typoname(expand('<amatch>'))
+<
invert({expr}) *invert()*
Bitwise invert. The argument is converted to a number. A
- List, Dict or Float argument causes an error. Example: >
- :let bits = invert(bits)
-< Can also be used as a |method|: >
- :let bits = bits->invert()
+ List, Dict or Float argument causes an error. Example: >vim
+ let bits = invert(bits)
+< Can also be used as a |method|: >vim
+ let bits = bits->invert()
+<
isdirectory({directory}) *isdirectory()*
The result is a Number, which is |TRUE| when a directory
@@ -4097,57 +4213,62 @@ isdirectory({directory}) *isdirectory()*
exist, or isn't a directory, the result is |FALSE|. {directory}
is any expression, which is used as a String.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->isdirectory()
+<
isinf({expr}) *isinf()*
Return 1 if {expr} is a positive infinity, or -1 a negative
- infinity, otherwise 0. >
- :echo isinf(1.0 / 0.0)
-< 1 >
- :echo isinf(-1.0 / 0.0)
+ infinity, otherwise 0. >vim
+ echo isinf(1.0 / 0.0)
+< 1 >vim
+ echo isinf(-1.0 / 0.0)
< -1
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->isinf()
+<
islocked({expr}) *islocked()* *E786*
The result is a Number, which is |TRUE| when {expr} is the
name of a locked variable.
The string argument {expr} must be the name of a variable,
|List| item or |Dictionary| entry, not the variable itself!
- Example: >
- :let alist = [0, ['a', 'b'], 2, 3]
- :lockvar 1 alist
- :echo islocked('alist') " 1
- :echo islocked('alist[1]') " 0
+ Example: >vim
+ let alist = [0, ['a', 'b'], 2, 3]
+ lockvar 1 alist
+ echo islocked('alist') " 1
+ echo islocked('alist[1]') " 0
< When {expr} is a variable that does not exist you get an error
message. Use |exists()| to check for existence.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->islocked()
+<
isnan({expr}) *isnan()*
- Return |TRUE| if {expr} is a float with value NaN. >
+ Return |TRUE| if {expr} is a float with value NaN. >vim
echo isnan(0.0 / 0.0)
< 1
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->isnan()
+<
items({dict}) *items()*
Return a |List| with all the key-value pairs of {dict}. Each
|List| item is a list with two items: the key of a {dict}
entry and the value of this entry. The |List| is in arbitrary
order. Also see |keys()| and |values()|.
- Example: >
+ Example: >vim
for [key, value] in items(mydict)
echo key .. ': ' .. value
endfor
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
mydict->items()
+<
jobpid({job}) *jobpid()*
Return the PID (process id) of |job-id| {job}.
@@ -4162,12 +4283,12 @@ jobstart({cmd} [, {opts}]) *jobstart()*
Spawns {cmd} as a job.
If {cmd} is a List it runs directly (no 'shell').
- If {cmd} is a String it runs in the 'shell', like this: >
- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+ If {cmd} is a String it runs in the 'shell', like this: >vim
+ call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
< (See |shell-unquoting| for details.)
- Example: >
- :call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
+ Example: >vim
+ call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
<
Returns |job-id| on success, 0 on invalid arguments (or job
table is full), -1 if {cmd}[0] or 'shell' is not executable.
@@ -4180,10 +4301,10 @@ jobstart({cmd} [, {opts}]) *jobstart()*
NOTE: on Windows if {cmd} is a List:
- cmd[0] must be an executable (not a "built-in"). If it is
- in $PATH it can be called by name, without an extension: >
- :call jobstart(['ping', 'neovim.io'])
-< If it is a full or partial path, extension is required: >
- :call jobstart(['System32\ping.exe', 'neovim.io'])
+ in $PATH it can be called by name, without an extension: >vim
+ call jobstart(['ping', 'neovim.io'])
+< If it is a full or partial path, extension is required: >vim
+ call jobstart(['System32\ping.exe', 'neovim.io'])
< - {cmd} is collapsed to a string of quoted args as expected
by CommandLineToArgvW https://msdn.microsoft.com/bb776391
unless cmd[0] is some form of "cmd.exe".
@@ -4260,7 +4381,7 @@ jobwait({jobs} [, {timeout}]) *jobwait()*
{timeout} is the maximum waiting time in milliseconds. If
omitted or -1, wait forever.
- Timeout of 0 can be used to check the status of a job: >
+ Timeout of 0 can be used to check the status of a job: >vim
let running = jobwait([{job-id}], 0)[0] == -1
<
During jobwait() callbacks for jobs not in the {jobs} list may
@@ -4279,14 +4400,15 @@ join({list} [, {sep}]) *join()*
When {sep} is specified it is put in between the items. If
{sep} is omitted a single space is used.
Note that {sep} is not added at the end. You might want to
- add it there too: >
+ add it there too: >vim
let lines = join(mylist, "\n") .. "\n"
< String items are used as-is. |Lists| and |Dictionaries| are
converted into a string like with |string()|.
The opposite function is |split()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->join()
+<
json_decode({expr}) *json_decode()*
Convert {expr} from JSON object. Accepts |readfile()|-style
@@ -4304,8 +4426,9 @@ json_decode({expr}) *json_decode()*
recommended and the only one required to be supported.
Non-UTF-8 characters are an error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
ReadObject()->json_decode()
+<
json_encode({expr}) *json_encode()*
Convert {expr} into a JSON string. Accepts
@@ -4319,24 +4442,26 @@ json_encode({expr}) *json_encode()*
or special escapes like "\t", other are dumped as-is.
|Blob|s are converted to arrays of the individual bytes.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetObject()->json_encode()
+<
keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
arbitrary order. Also see |items()| and |values()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mydict->keys()
+<
keytrans({string}) *keytrans()*
Turn the internal byte representation of keys into a form that
- can be used for |:map|. E.g. >
- :let xx = "\<C-Home>"
- :echo keytrans(xx)
+ can be used for |:map|. E.g. >vim
+ let xx = "\<C-Home>"
+ echo keytrans(xx)
< <C-Home>
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
"\<C-Home>"->keytrans()
<
@@ -4350,7 +4475,7 @@ len({expr}) *len()* *E701*
|Dictionary| is returned.
Otherwise an error is given and returns zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->len()
<
@@ -4393,24 +4518,24 @@ libcall({libname}, {funcname}, {argument}) *libcall()* *E364* *E368*
the DLL is not in the usual places.
For Unix: When compiling your own plugins, remember that the
object code must be compiled as position-independent ('PIC').
- Examples: >
- :echo libcall("libc.so", "getenv", "HOME")
+ Examples: >vim
+ echo libcall("libc.so", "getenv", "HOME")
< Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->libcall("libc.so", "getenv")
<
libcallnr({libname}, {funcname}, {argument}) *libcallnr()*
Just like |libcall()|, but used for a function that returns an
int instead of a string.
- Examples: >
- :echo libcallnr("/usr/lib/libc.so", "getpid", "")
- :call libcallnr("libc.so", "printf", "Hello World!\n")
- :call libcallnr("libc.so", "sleep", 10)
+ Examples: >vim
+ echo libcallnr("/usr/lib/libc.so", "getpid", "")
+ call libcallnr("libc.so", "printf", "Hello World!\n")
+ call libcallnr("libc.so", "sleep", 10)
<
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->libcallnr("libc.so", "printf")
<
@@ -4437,17 +4562,18 @@ line({expr} [, {winid}]) *line()*
With the optional {winid} argument the values are obtained for
that window instead of the current window.
Returns 0 for invalid values of {expr} and {winid}.
- Examples: >
- line(".") line number of the cursor
- line(".", winid) idem, in window "winid"
- line("'t") line number of mark t
- line("'" .. marker) line number of mark marker
+ Examples: >vim
+ echo line(".") " line number of the cursor
+ echo line(".", winid) " idem, in window "winid"
+ echo line("'t") " line number of mark t
+ echo line("'" .. marker) " line number of mark marker
<
To jump to the last known position when opening a file see
|last-position-jump|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetValue()->line()
+<
line2byte({lnum}) *line2byte()*
Return the byte count from the start of the buffer for line
@@ -4455,15 +4581,16 @@ line2byte({lnum}) *line2byte()*
the 'fileformat' option for the current buffer. The first
line returns 1. UTF-8 encoding is used, 'fileencoding' is
ignored. This can also be used to get the byte count for the
- line just below the last line: >
- line2byte(line("$") + 1)
+ line just below the last line: >vim
+ echo line2byte(line("$") + 1)
< This is the buffer size plus one. If 'fileencoding' is empty
it is the file size plus one. {lnum} is used like with
|getline()|. When {lnum} is invalid -1 is returned.
Also see |byte2line()|, |go| and |:goto|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->line2byte()
+<
lispindent({lnum}) *lispindent()*
Get the amount of indent for line {lnum} according the lisp
@@ -4472,40 +4599,43 @@ lispindent({lnum}) *lispindent()*
relevant. {lnum} is used just like in |getline()|.
When {lnum} is invalid, -1 is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->lispindent()
+<
list2blob({list}) *list2blob()*
Return a Blob concatenating all the number values in {list}.
- Examples: >
- list2blob([1, 2, 3, 4]) returns 0z01020304
- list2blob([]) returns 0z
+ Examples: >vim
+ echo list2blob([1, 2, 3, 4]) " returns 0z01020304
+ echo list2blob([]) " returns 0z
< Returns an empty Blob on error. If one of the numbers is
negative or more than 255 error *E1239* is given.
|blob2list()| does the opposite.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetList()->list2blob()
+<
list2str({list} [, {utf8}]) *list2str()*
Convert each number in {list} to a character string can
- concatenate them all. Examples: >
- list2str([32]) returns " "
- list2str([65, 66, 67]) returns "ABC"
-< The same can be done (slowly) with: >
- join(map(list, {nr, val -> nr2char(val)}), '')
+ concatenate them all. Examples: >vim
+ echo list2str([32]) " returns " "
+ echo list2str([65, 66, 67]) " returns "ABC"
+< The same can be done (slowly) with: >vim
+ echo join(map(list, {nr, val -> nr2char(val)}), '')
< |str2list()| does the opposite.
UTF-8 encoding is always used, {utf8} option has no effect,
and exists only for backwards-compatibility.
- With UTF-8 composing characters work as expected: >
- list2str([97, 769]) returns "á"
+ With UTF-8 composing characters work as expected: >vim
+ echo list2str([97, 769]) " returns "á"
<
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetList()->list2str()
+<
localtime() *localtime()*
Return the current time, measured as seconds since 1st Jan
@@ -4516,33 +4646,35 @@ log({expr}) *log()*
{expr} must evaluate to a |Float| or a |Number| in the range
(0, inf].
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo log(10)
-< 2.302585 >
- :echo log(exp(5))
+ Examples: >vim
+ echo log(10)
+< 2.302585 >vim
+ echo log(exp(5))
< 5.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->log()
+<
log10({expr}) *log10()*
Return the logarithm of Float {expr} to base 10 as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo log10(1000)
-< 3.0 >
- :echo log10(0.01)
+ Examples: >vim
+ echo log10(1000)
+< 3.0 >vim
+ echo log10(0.01)
< -2.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->log10()
+<
luaeval({expr} [, {expr}]) *luaeval()*
Evaluate Lua expression {expr} and return its result converted
to Vim data structures. See |lua-eval| for more details.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->luaeval()
<
@@ -4558,8 +4690,8 @@ map({expr1}, {expr2}) *map()*
of the current item and for a |List| |v:key| has the index of
the current item. For a |Blob| |v:key| has the index of the
current byte.
- Example: >
- :call map(mylist, '"> " .. v:val .. " <"')
+ Example: >vim
+ call map(mylist, '"> " .. v:val .. " <"')
< This puts "> " before and " <" after each item in "mylist".
Note that {expr2} is the result of an expression and is then
@@ -4571,21 +4703,21 @@ map({expr1}, {expr2}) *map()*
1. The key or the index of the current item.
2. the value of the current item.
The function must return the new value of the item. Example
- that changes each value by "key-value": >
+ that changes each value by "key-value": >vim
func KeyValue(key, val)
return a:key .. '-' .. a:val
endfunc
call map(myDict, function('KeyValue'))
-< It is shorter when using a |lambda|: >
+< It is shorter when using a |lambda|: >vim
call map(myDict, {key, val -> key .. '-' .. val})
-< If you do not use "val" you can leave it out: >
+< If you do not use "val" you can leave it out: >vim
call map(myDict, {key -> 'item: ' .. key})
-< If you do not use "key" you can use a short name: >
+< If you do not use "key" you can use a short name: >vim
call map(myDict, {_, val -> 'item: ' .. val})
<
The operation is done in-place. If you want a |List| or
- |Dictionary| to remain unmodified make a copy first: >
- :let tlist = map(copy(mylist), ' v:val .. "\t"')
+ |Dictionary| to remain unmodified make a copy first: >vim
+ let tlist = map(copy(mylist), ' v:val .. "\t"')
< Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
filtered. When an error is encountered while evaluating
@@ -4593,7 +4725,7 @@ map({expr1}, {expr2}) *map()*
{expr2} is a Funcref errors inside a function are ignored,
unless it was defined with the "abort" flag.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->map(expr2)
<
@@ -4658,11 +4790,12 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
The mappings local to the current buffer are checked first,
then the global mappings.
This function can be used to map a key even when it's already
- mapped, and have it do the original mapping too. Sketch: >
+ mapped, and have it do the original mapping too. Sketch: >vim
exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetKey()->maparg('n')
+<
mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
Check if there is a mapping that matches with {name} in mode
@@ -4690,15 +4823,16 @@ mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
The mappings local to the current buffer are checked first,
then the global mappings.
This function can be used to check if a mapping can be added
- without being ambiguous. Example: >
- :if mapcheck("_vv") == ""
- : map _vv :set guifont=7x13<CR>
- :endif
+ without being ambiguous. Example: >vim
+ if mapcheck("_vv") == ""
+ map _vv :set guifont=7x13<CR>
+ endif
< This avoids adding the "_vv" mapping when there already is a
mapping for "_v" or for "_vvv".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetKey()->mapcheck('n')
+<
mapset({mode}, {abbr}, {dict}) *mapset()*
Restore a mapping from a dictionary returned by |maparg()|.
@@ -4706,10 +4840,10 @@ mapset({mode}, {abbr}, {dict}) *mapset()*
|maparg()|. *E460*
{mode} is used to define the mode in which the mapping is set,
not the "mode" entry in {dict}.
- Example for saving and restoring a mapping: >
+ Example for saving and restoring a mapping: >vim
let save_map = maparg('K', 'n', 0, 1)
nnoremap K somethingelse
- ...
+ " ...
call mapset('n', 0, save_map)
< Note that if you are going to replace a map in several modes,
e.g. with `:map!`, you need to save the mapping for all of
@@ -4728,27 +4862,27 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()*
If there is no match -1 is returned.
For getting submatches see |matchlist()|.
- Example: >
- :echo match("testing", "ing") " results in 4
- :echo match([1, 'x'], '\a') " results in 1
+ Example: >vim
+ echo match("testing", "ing") " results in 4
+ echo match([1, 'x'], '\a') " results in 1
< See |string-match| for how {pat} is used.
*strpbrk()*
- Vim doesn't have a strpbrk() function. But you can do: >
- :let sepidx = match(line, '[.,;: \t]')
+ Vim doesn't have a strpbrk() function. But you can do: >vim
+ let sepidx = match(line, '[.,;: \t]')
< *strcasestr()*
Vim doesn't have a strcasestr() function. But you can add
- "\c" to the pattern to ignore case: >
- :let idx = match(haystack, '\cneedle')
+ "\c" to the pattern to ignore case: >vim
+ let idx = match(haystack, '\cneedle')
<
If {start} is given, the search starts from byte index
{start} in a String or item {start} in a |List|.
The result, however, is still the index counted from the
- first character/item. Example: >
- :echo match("testing", "ing", 2)
-< result is again "4". >
- :echo match("testing", "ing", 4)
-< result is again "4". >
- :echo match("testing", "t", 2)
+ first character/item. Example: >vim
+ echo match("testing", "ing", 2)
+< result is again "4". >vim
+ echo match("testing", "ing", 4)
+< result is again "4". >vim
+ echo match("testing", "t", 2)
< result is "3".
For a String, if {start} > 0 then it is like the string starts
{start} bytes later, thus "^" will match at {start}. Except
@@ -4762,7 +4896,7 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()*
When {count} is given use the {count}th match. When a match
is found in a String the search for the next one starts one
- character further. Thus this example results in 1: >
+ character further. Thus this example results in 1: >vim
echo match("testing", "..", 0, 2)
< In a |List| the search continues in the next item.
Note that when {count} is added the way {start} works changes,
@@ -4777,7 +4911,7 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()*
zero matches at the start instead of a number of matches
further down in the text.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->match('word')
GetList()->match('word')
<
@@ -4831,17 +4965,17 @@ matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
Returns -1 on error.
- Example: >
- :highlight MyGroup ctermbg=green guibg=green
- :let m = matchadd("MyGroup", "TODO")
-< Deletion of the pattern: >
- :call matchdelete(m)
+ Example: >vim
+ highlight MyGroup ctermbg=green guibg=green
+ let m = matchadd("MyGroup", "TODO")
+< Deletion of the pattern: >vim
+ call matchdelete(m)
< A list of matches defined by |matchadd()| and |:match| are
available from |getmatches()|. All matches can be deleted in
one operation by |clearmatches()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetGroup()->matchadd('TODO')
<
@@ -4873,17 +5007,18 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()*
Returns -1 on error.
- Example: >
- :highlight MyGroup ctermbg=green guibg=green
- :let m = matchaddpos("MyGroup", [[23, 24], 34])
-< Deletion of the pattern: >
- :call matchdelete(m)
+ Example: >vim
+ highlight MyGroup ctermbg=green guibg=green
+ let m = matchaddpos("MyGroup", [[23, 24], 34])
+< Deletion of the pattern: >vim
+ call matchdelete(m)
< Matches added by |matchaddpos()| are returned by
|getmatches()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetGroup()->matchaddpos([23, 11])
+<
matcharg({nr}) *matcharg()*
Selects the {nr} match item, as set with a |:match|,
@@ -4897,8 +5032,9 @@ matcharg({nr}) *matcharg()*
Highlighting matches using the |:match| commands are limited
to three matches. |matchadd()| does not have this limitation.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMatch()->matcharg()
+<
matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
Deletes a match with ID {id} previously defined by |matchadd()|
@@ -4908,30 +5044,32 @@ matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
If {win} is specified, use the window with this number or
window ID instead of the current window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMatch()->matchdelete()
+<
matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
Same as |match()|, but return the index of first character
- after the match. Example: >
- :echo matchend("testing", "ing")
+ after the match. Example: >vim
+ echo matchend("testing", "ing")
< results in "7".
*strspn()* *strcspn()*
Vim doesn't have a strspn() or strcspn() function, but you can
- do it with matchend(): >
- :let span = matchend(line, '[a-zA-Z]')
- :let span = matchend(line, '[^a-zA-Z]')
+ do it with matchend(): >vim
+ let span = matchend(line, '[a-zA-Z]')
+ let span = matchend(line, '[^a-zA-Z]')
< Except that -1 is returned when there are no matches.
- The {start}, if given, has the same meaning as for |match()|. >
- :echo matchend("testing", "ing", 2)
-< results in "7". >
- :echo matchend("testing", "ing", 5)
+ The {start}, if given, has the same meaning as for |match()|. >vim
+ echo matchend("testing", "ing", 2)
+< results in "7". >vim
+ echo matchend("testing", "ing", 5)
< result is "-1".
When {expr} is a |List| the result is equal to |match()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchend('word')
+<
matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
If {list} is a list of strings, then returns a |List| with all
@@ -4974,25 +5112,25 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
Refer to |fuzzy-matching| for more information about fuzzy
matching strings.
- Example: >
- :echo matchfuzzy(["clay", "crow"], "cay")
-< results in ["clay"]. >
- :echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
-< results in a list of buffer names fuzzy matching "ndl". >
- :echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
+ Example: >vim
+ echo matchfuzzy(["clay", "crow"], "cay")
+< results in ["clay"]. >vim
+ echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
+< results in a list of buffer names fuzzy matching "ndl". >vim
+ echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
< results in a list of buffer information dicts with buffer
- names fuzzy matching "ndl". >
- :echo getbufinfo()->matchfuzzy("spl",
+ names fuzzy matching "ndl". >vim
+ echo getbufinfo()->matchfuzzy("spl",
\ {'text_cb' : {v -> v.name}})
< results in a list of buffer information dicts with buffer
- names fuzzy matching "spl". >
- :echo v:oldfiles->matchfuzzy("test")
-< results in a list of file names fuzzy matching "test". >
- :let l = readfile("buffer.c")->matchfuzzy("str")
-< results in a list of lines in "buffer.c" fuzzy matching "str". >
- :echo ['one two', 'two one']->matchfuzzy('two one')
-< results in `['two one', 'one two']` . >
- :echo ['one two', 'two one']->matchfuzzy('two one',
+ names fuzzy matching "spl". >vim
+ echo v:oldfiles->matchfuzzy("test")
+< results in a list of file names fuzzy matching "test". >vim
+ let l = readfile("buffer.c")->matchfuzzy("str")
+< results in a list of lines in "buffer.c" fuzzy matching "str". >vim
+ echo ['one two', 'two one']->matchfuzzy('two one')
+< results in `['two one', 'one two']` . >vim
+ echo ['one two', 'two one']->matchfuzzy('two one',
\ {'matchseq': 1})
< results in `['two one']`.
@@ -5009,12 +5147,12 @@ matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
If there are no matching strings or there is an error, then a
list with three empty list items is returned.
- Example: >
- :echo matchfuzzypos(['testing'], 'tsg')
-< results in [["testing"], [[0, 2, 6]], [99]] >
- :echo matchfuzzypos(['clay', 'lacy'], 'la')
-< results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >
- :echo [{'text': 'hello', 'id' : 10}]
+ Example: >vim
+ echo matchfuzzypos(['testing'], 'tsg')
+< results in [["testing"], [[0, 2, 6]], [99]] >vim
+ echo matchfuzzypos(['clay', 'lacy'], 'la')
+< results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
+ echo [{'text': 'hello', 'id' : 10}]
\ ->matchfuzzypos('ll', {'key' : 'text'})
< results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
@@ -5023,56 +5161,58 @@ matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
list is the matched string, same as what matchstr() would
return. Following items are submatches, like "\1", "\2", etc.
in |:substitute|. When an optional submatch didn't match an
- empty string is used. Example: >
+ empty string is used. Example: >vim
echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
< Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
When there is no match an empty list is returned.
You can pass in a List, but that is not very useful.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchlist('word')
+<
matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
- Same as |match()|, but return the matched string. Example: >
- :echo matchstr("testing", "ing")
+ Same as |match()|, but return the matched string. Example: >vim
+ echo matchstr("testing", "ing")
< results in "ing".
When there is no match "" is returned.
- The {start}, if given, has the same meaning as for |match()|. >
- :echo matchstr("testing", "ing", 2)
-< results in "ing". >
- :echo matchstr("testing", "ing", 5)
+ The {start}, if given, has the same meaning as for |match()|. >vim
+ echo matchstr("testing", "ing", 2)
+< results in "ing". >vim
+ echo matchstr("testing", "ing", 5)
< result is "".
When {expr} is a |List| then the matching item is returned.
The type isn't changed, it's not necessarily a String.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchstr('word')
+<
matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
Same as |matchstr()|, but return the matched string, the start
- position and the end position of the match. Example: >
- :echo matchstrpos("testing", "ing")
+ position and the end position of the match. Example: >vim
+ echo matchstrpos("testing", "ing")
< results in ["ing", 4, 7].
When there is no match ["", -1, -1] is returned.
- The {start}, if given, has the same meaning as for |match()|. >
- :echo matchstrpos("testing", "ing", 2)
-< results in ["ing", 4, 7]. >
- :echo matchstrpos("testing", "ing", 5)
+ The {start}, if given, has the same meaning as for |match()|. >vim
+ echo matchstrpos("testing", "ing", 2)
+< results in ["ing", 4, 7]. >vim
+ echo matchstrpos("testing", "ing", 5)
< result is ["", -1, -1].
When {expr} is a |List| then the matching item, the index
of first item where {pat} matches, the start position and the
- end position of the match are returned. >
- :echo matchstrpos([1, '__x'], '\a')
+ end position of the match are returned. >vim
+ echo matchstrpos([1, '__x'], '\a')
< result is ["x", 1, 2, 3].
The type isn't changed, it's not necessarily a String.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchstrpos('word')
<
max({expr}) *max()*
- Return the maximum value of all items in {expr}. Example: >
+ Return the maximum value of all items in {expr}. Example: >vim
echo max([apples, pears, oranges])
< {expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -5081,7 +5221,7 @@ max({expr}) *max()*
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->max()
<
@@ -5090,14 +5230,14 @@ menu_get({path} [, {modes}]) *menu_get()*
by |:menu|, |:amenu|, …), including |hidden-menus|.
{path} matches a menu by name, or all menus if {path} is an
- empty string. Example: >
- :echo menu_get('File','')
- :echo menu_get('')
+ empty string. Example: >vim
+ echo menu_get('File','')
+ echo menu_get('')
<
{modes} is a string of zero or more modes (see |maparg()| or
|creating-menus| for the list of modes). "a" means "all".
- Example: >
+ Example: >vim
nnoremenu &Test.Test inormal
inoremenu Test.Test insert
vnoremenu Test.Test x
@@ -5183,9 +5323,9 @@ menu_info({name} [, {mode}]) *menu_info()*
Returns an empty dictionary if the menu item is not found.
- Examples: >
- :echo menu_info('Edit.Cut')
- :echo menu_info('File.Save', 'n')
+ Examples: >vim
+ echo menu_info('Edit.Cut')
+ echo menu_info('File.Save', 'n')
" Display the entire menu hierarchy in a buffer
func ShowMenu(name, pfx)
@@ -5201,12 +5341,12 @@ menu_info({name} [, {mode}]) *menu_info()*
call ShowMenu(topmenu, '')
endfor
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMenuName()->menu_info('v')
<
min({expr}) *min()*
- Return the minimum value of all items in {expr}. Example: >
+ Return the minimum value of all items in {expr}. Example: >vim
echo min([apples, pears, oranges])
< {expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -5215,7 +5355,7 @@ min({expr}) *min()*
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->min()
<
@@ -5229,19 +5369,19 @@ mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739*
created as necessary.
If {flags} contains "D" then {name} is deleted at the end of
- the current function, as with: >
+ the current function, as with: >vim
defer delete({name}, 'd')
<
If {flags} contains "R" then {name} is deleted recursively at
- the end of the current function, as with: >
+ the end of the current function, as with: >vim
defer delete({name}, 'rf')
< Note that when {name} has more than one part and "p" is used
some directories may already exist. Only the first one that
is created and what it contains is scheduled to be deleted.
- E.g. when using: >
+ E.g. when using: >vim
call mkdir('subdir/tmp/autoload', 'pR')
< and "subdir" already exists then "subdir/tmp" will be
- scheduled for deletion, like with: >
+ scheduled for deletion, like with: >vim
defer delete('subdir/tmp', 'rf')
<
If {prot} is given it is used to set the protection bits of
@@ -5250,8 +5390,8 @@ mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739*
unreadable for others.
{prot} is applied for all parts of {name}. Thus if you create
- /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >
- :call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
+ /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
+ call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
< This function is not available in the |sandbox|.
@@ -5262,7 +5402,7 @@ mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739*
successful or FALSE if the directory creation failed or partly
failed.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->mkdir()
<
@@ -5317,15 +5457,16 @@ mode([expr]) *mode()*
the leading character(s).
Also see |visualmode()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
DoFull()->mode()
+<
msgpackdump({list} [, {type}]) *msgpackdump()*
Convert a list of Vimscript objects to msgpack. Returned value is a
|readfile()|-style list. When {type} contains "B", a |Blob| is
- returned instead. Example: >
+ returned instead. Example: >vim
call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
-< or, using a |Blob|: >
+< or, using a |Blob|: >vim
call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
<
This will write the single 0x80 byte to a `fname.mpack` file
@@ -5342,7 +5483,7 @@ msgpackdump({list} [, {type}]) *msgpackdump()*
msgpackparse({data}) *msgpackparse()*
Convert a |readfile()|-style list or a |Blob| to a list of
Vimscript objects.
- Example: >
+ Example: >vim
let fname = expand('~/.config/nvim/shada/main.shada')
let mpack = readfile(fname, 'b')
let shada_objects = msgpackparse(mpack)
@@ -5415,31 +5556,33 @@ msgpackparse({data}) *msgpackparse()*
nextnonblank({lnum}) *nextnonblank()*
Return the line number of the first line at or below {lnum}
- that is not blank. Example: >
- if getline(nextnonblank(1)) =~ "Java"
+ that is not blank. Example: >vim
+ if getline(nextnonblank(1)) =~ "Java" | endif
< When {lnum} is invalid or there is no non-blank line at or
below it, zero is returned.
{lnum} is used like with |getline()|.
See also |prevnonblank()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->nextnonblank()
+<
nr2char({expr} [, {utf8}]) *nr2char()*
Return a string with a single character, which has the number
- value {expr}. Examples: >
- nr2char(64) returns "@"
- nr2char(32) returns " "
-< Example for "utf-8": >
- nr2char(300) returns I with bow character
- <UTF-8 encoding is always used, {utf8} option has no effect,
+ value {expr}. Examples: >vim
+ echo nr2char(64) " returns '@'
+ echo nr2char(32) " returns ' '
+< Example for "utf-8": >vim
+ echo nr2char(300) " returns I with bow character
+<
+ UTF-8 encoding is always used, {utf8} option has no effect,
and exists only for backwards-compatibility.
Note that a NUL character in the file is specified with
nr2char(10), because NULs are represented with newline
characters. nr2char(0) is a real NUL and terminates the
string, thus results in an empty string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetNumber()->nr2char()
<
@@ -5458,10 +5601,10 @@ or({expr}, {expr}) *or()*
Bitwise OR on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see `and()` and `xor()`.
- Example: >
- :let bits = or(bits, 0x80)
-< Can also be used as a |method|: >
- :let bits = bits->or(0x80)
+ Example: >vim
+ let bits = or(bits, 0x80)
+< Can also be used as a |method|: >vim
+ let bits = bits->or(0x80)
< Rationale: The reason this is a function and not using the "|"
character like many languages, is that Vi has always used "|"
@@ -5473,17 +5616,18 @@ pathshorten({path} [, {len}]) *pathshorten()*
result. The tail, the file name, is kept as-is. The other
components in the path are reduced to {len} letters in length.
If {len} is omitted or smaller than 1 then 1 is used (single
- letters). Leading '~' and '.' characters are kept. Examples: >
- :echo pathshorten('~/.config/nvim/autoload/file1.vim')
+ letters). Leading '~' and '.' characters are kept. Examples: >vim
+ echo pathshorten('~/.config/nvim/autoload/file1.vim')
< ~/.c/n/a/file1.vim ~
- >
- :echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
+ >vim
+ echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
< ~/.co/nv/au/file2.vim ~
It doesn't matter if the path exists or not.
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetDirectories()->pathshorten()
+<
perleval({expr}) *perleval()*
Evaluate |perl| expression {expr} and return its result
@@ -5496,49 +5640,52 @@ perleval({expr}) *perleval()*
Note: If you want an array or hash, {expr} must return a
reference to it.
- Example: >
- :echo perleval('[1 .. 4]')
+ Example: >vim
+ echo perleval('[1 .. 4]')
< [1, 2, 3, 4]
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->perleval()
+<
pow({x}, {y}) *pow()*
Return the power of {x} to the exponent {y} as a |Float|.
{x} and {y} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
- Examples: >
- :echo pow(3, 3)
-< 27.0 >
- :echo pow(2, 16)
-< 65536.0 >
- :echo pow(32, 0.20)
+ Examples: >vim
+ echo pow(3, 3)
+< 27.0 >vim
+ echo pow(2, 16)
+< 65536.0 >vim
+ echo pow(32, 0.20)
< 2.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->pow(3)
+<
prevnonblank({lnum}) *prevnonblank()*
Return the line number of the first line at or above {lnum}
- that is not blank. Example: >
+ that is not blank. Example: >vim
let ind = indent(prevnonblank(v:lnum - 1))
< When {lnum} is invalid or there is no non-blank line at or
above it, zero is returned.
{lnum} is used like with |getline()|.
Also see |nextnonblank()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->prevnonblank()
+<
printf({fmt}, {expr1} ...) *printf()*
Return a String with {fmt}, where "%" items are replaced by
- the formatted form of their respective arguments. Example: >
- printf("%4d: E%d %.30s", lnum, errno, msg)
+ the formatted form of their respective arguments. Example: >vim
+ echo printf("%4d: E%d %.30s", lnum, errno, msg)
< May result in:
" 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
When used as a |method| the base is passed as the second
- argument: >
+ argument: >vim
Compute()->printf("result: %d")
<
You can use `call()` to pass the items as a list.
@@ -5638,8 +5785,8 @@ printf({fmt}, {expr1} ...) *printf()*
Number argument supplies the field width or precision. A
negative field width is treated as a left adjustment flag
followed by a positive field width; a negative precision is
- treated as though it were missing. Example: >
- :echo printf("%d: %.*s", nr, width, line)
+ treated as though it were missing. Example: >vim
+ echo printf("%d: %.*s", nr, width, line)
< This limits the length of the text used from "line" to
"width" bytes.
@@ -5694,7 +5841,7 @@ printf({fmt}, {expr1} ...) *printf()*
(out of range or dividing by zero) results in "inf"
or "-inf" with %f (INF or -INF with %F).
"0.0 / 0.0" results in "nan" with %f (NAN with %F).
- Example: >
+ Example: >vim
echo printf("%.2f", 12.115)
< 12.12
Note that roundoff depends on the system libraries.
@@ -5737,8 +5884,9 @@ prompt_getprompt({buf}) *prompt_getprompt()*
If the buffer doesn't exist or isn't a prompt buffer, an empty
string is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->prompt_getprompt()
+<
prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
Set prompt callback for buffer {buf} to {expr}. When {expr}
@@ -5756,7 +5904,7 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
The callback is invoked with one argument, which is the text
that was entered at the prompt. This can be an empty string
if the user only typed Enter.
- Example: >
+ Example: >vim
func s:TextEntered(text)
if a:text == 'exit' || a:text == 'quit'
stopinsert
@@ -5772,8 +5920,9 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
endfunc
call prompt_setcallback(bufnr(), function('s:TextEntered'))
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetBuffer()->prompt_setcallback(callback)
+<
prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
Set a callback for buffer {buf} to {expr}. When {expr} is an
@@ -5784,18 +5933,20 @@ prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
mode. Without setting a callback Vim will exit Insert mode,
as in any buffer.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->prompt_setinterrupt(callback)
+<
prompt_setprompt({buf}, {text}) *prompt_setprompt()*
Set prompt for buffer {buf} to {text}. You most likely want
{text} to end in a space.
The result is only visible if {buf} has 'buftype' set to
- "prompt". Example: >
+ "prompt". Example: >vim
call prompt_setprompt(bufnr(''), 'command: ')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->prompt_setprompt('command: ')
+<
pum_getpos() *pum_getpos()*
If the popup menu (see |ins-completion-menu|) is not visible,
@@ -5826,7 +5977,7 @@ py3eval({expr}) *py3eval()*
Dictionaries are represented as Vim |Dictionary| type with
keys converted to strings.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->py3eval()
<
@@ -5839,8 +5990,9 @@ pyeval({expr}) *pyeval()* *E858* *E859*
Dictionaries are represented as Vim |Dictionary| type,
non-string keys result in error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->pyeval()
+<
pyxeval({expr}) *pyxeval()*
Evaluate Python expression {expr} and return its result
@@ -5848,7 +6000,7 @@ pyxeval({expr}) *pyxeval()*
Uses Python 2 or 3, see |python_x| and 'pyxversion'.
See also: |pyeval()|, |py3eval()|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->pyxeval()
<
@@ -5861,13 +6013,13 @@ rand([{expr}]) *rand()*
and updated.
Returns -1 if {expr} is invalid.
- Examples: >
- :echo rand()
- :let seed = srand()
- :echo rand(seed)
- :echo rand(seed) % 16 " random number 0 - 15
+ Examples: >vim
+ echo rand()
+ let seed = srand()
+ echo rand(seed)
+ echo rand(seed) % 16 " random number 0 - 15
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
seed->rand()
<
@@ -5881,15 +6033,15 @@ range({expr} [, {max} [, {stride}]]) *range()* *E726* *E727*
When the maximum is one before the start the result is an
empty list. When the maximum is more than one before the
start this is an error.
- Examples: >
- range(4) " [0, 1, 2, 3]
- range(2, 4) " [2, 3, 4]
- range(2, 9, 3) " [2, 5, 8]
- range(2, -2, -1) " [2, 1, 0, -1, -2]
- range(0) " []
- range(2, 0) " error!
-<
- Can also be used as a |method|: >
+ Examples: >vim
+ echo range(4) " [0, 1, 2, 3]
+ echo range(2, 4) " [2, 3, 4]
+ echo range(2, 9, 3) " [2, 5, 8]
+ echo range(2, -2, -1) " [2, 1, 0, -1, -2]
+ echo range(0) " []
+ echo range(2, 0) " error!
+<
+ Can also be used as a |method|: >vim
GetExpr()->range()
<
@@ -5897,18 +6049,18 @@ readblob({fname} [, {offset} [, {size}]]) *readblob()*
Read file {fname} in binary mode and return a |Blob|.
If {offset} is specified, read the file from the specified
offset. If it is a negative value, it is used as an offset
- from the end of the file. E.g., to read the last 12 bytes: >
- readblob('file.bin', -12)
+ from the end of the file. E.g., to read the last 12 bytes: >vim
+ echo readblob('file.bin', -12)
< If {size} is specified, only the specified size will be read.
- E.g. to read the first 100 bytes of a file: >
- readblob('file.bin', 0, 100)
+ E.g. to read the first 100 bytes of a file: >vim
+ echo readblob('file.bin', 0, 100)
< If {size} is -1 or omitted, the whole data starting from
{offset} will be read.
This can be also used to read the data from a character device
on Unix when {size} is explicitly set. Only if the device
supports seeking {offset} can be used. Otherwise it should be
- zero. E.g. to read 10 bytes from a serial console: >
- readblob('/dev/ttyS0', 0, 10)
+ zero. E.g. to read 10 bytes from a serial console: >vim
+ echo readblob('/dev/ttyS0', 0, 10)
< When the file can't be opened an error message is given and
the result is an empty |Blob|.
When the offset is beyond the end of the file the result is an
@@ -5932,12 +6084,12 @@ readdir({directory} [, {expr}]) *readdir()*
to the list.
Each time {expr} is evaluated |v:val| is set to the entry name.
When {expr} is a function the name is passed as the argument.
- For example, to get a list of files ending in ".txt": >
- readdir(dirname, {n -> n =~ '.txt$'})
-< To skip hidden and backup files: >
- readdir(dirname, {n -> n !~ '^\.\|\~$'})
+ For example, to get a list of files ending in ".txt": >vim
+ echo readdir(dirname, {n -> n =~ '.txt$'})
+< To skip hidden and backup files: >vim
+ echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
-< If you want to get a directory tree: >
+< If you want to get a directory tree: >vim
function! s:tree(dir)
return {a:dir : map(readdir(a:dir),
\ {_, x -> isdirectory(x) ?
@@ -5947,7 +6099,7 @@ readdir({directory} [, {expr}]) *readdir()*
<
Returns an empty List on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetDirName()->readdir()
<
@@ -5967,10 +6119,10 @@ readfile({fname} [, {type} [, {max}]]) *readfile()*
- Any UTF-8 byte order mark is removed from the text.
When {max} is given this specifies the maximum number of lines
to be read. Useful if you only want to check the first ten
- lines of a file: >
- :for line in readfile(fname, '', 10)
- : if line =~ 'Date' | echo line | endif
- :endfor
+ lines of a file: >vim
+ for line in readfile(fname, '', 10)
+ if line =~ 'Date' | echo line | endif
+ endfor
< When {max} is negative -{max} lines from the end of the file
are returned, or as many as there are.
When {max} is zero the result is an empty list.
@@ -5984,7 +6136,7 @@ readfile({fname} [, {type} [, {max}]]) *readfile()*
the result is an empty list.
Also see |writefile()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFileName()->readfile()
<
@@ -5999,13 +6151,14 @@ reduce({object}, {func} [, {initial}]) *reduce()* *E998*
item. If {initial} is not given and {object} is empty no
result can be computed, an E998 error is given.
- Examples: >
+ Examples: >vim
echo reduce([1, 3, 5], { acc, val -> acc + val })
echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
echo reduce(0z1122, { acc, val -> 2 * acc + val })
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
echo mylist->reduce({ acc, val -> acc + val }, 0)
+<
reg_executing() *reg_executing()*
Returns the single letter name of the register being executed.
@@ -6041,7 +6194,7 @@ reltime({start}, {end}) *reltime()*
The {start} and {end} arguments must be values returned by
reltime(). Returns zero on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetStart()->reltime()
<
Note: |localtime()| returns the current (non-relative) time.
@@ -6057,25 +6210,26 @@ reltimefloat({time}) *reltimefloat()*
Also see |profiling|.
If there is an error an empty string is returned
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
reltime(start)->reltimefloat()
+<
reltimestr({time}) *reltimestr()*
Return a String that represents the time value of {time}.
This is the number of seconds, a dot and the number of
- microseconds. Example: >
+ microseconds. Example: >vim
let start = reltime()
call MyFunction()
echo reltimestr(reltime(start))
< Note that overhead for the commands will be added to the time.
Leading spaces are used to make the string align nicely. You
- can use split() to remove it. >
+ can use split() to remove it. >vim
echo split(reltimestr(reltime(start)))[0]
< Also see |profiling|.
If there is an error an empty string is returned
- Can also be used as a |method|: >
- reltime(start)->reltimestr()
+ Can also be used as a |method|: >vim
+ echo reltime(start)->reltimestr()
<
remove({list}, {idx})
@@ -6088,14 +6242,15 @@ remove({list}, {idx}, {end}) *remove()*
points to an item before {idx} this is an error.
See |list-index| for possible values of {idx} and {end}.
Returns zero on error.
- Example: >
- :echo "last item: " .. remove(mylist, -1)
- :call remove(mylist, 0, 9)
+ Example: >vim
+ echo "last item: " .. remove(mylist, -1)
+ call remove(mylist, 0, 9)
<
Use |delete()| to remove a file.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->remove(idx)
+<
remove({blob}, {idx})
remove({blob}, {idx}, {end})
@@ -6106,14 +6261,15 @@ remove({blob}, {idx}, {end})
byte as {end} a |Blob| with one byte is returned. When {end}
points to a byte before {idx} this is an error.
Returns zero on error.
- Example: >
- :echo "last byte: " .. remove(myblob, -1)
- :call remove(mylist, 0, 9)
+ Example: >vim
+ echo "last byte: " .. remove(myblob, -1)
+ call remove(mylist, 0, 9)
+<
remove({dict}, {key})
Remove the entry from {dict} with key {key} and return it.
- Example: >
- :echo "removed " .. remove(dict, "one")
+ Example: >vim
+ echo "removed " .. remove(dict, "one")
< If there is no {key} in {dict} this is an error.
Returns zero on error.
@@ -6125,20 +6281,21 @@ rename({from}, {to}) *rename()*
NOTE: If {to} exists it is overwritten without warning.
This function is not available in the |sandbox|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetOldName()->rename(newname)
+<
repeat({expr}, {count}) *repeat()*
Repeat {expr} {count} times and return the concatenated
- result. Example: >
- :let separator = repeat('-', 80)
+ result. Example: >vim
+ let separator = repeat('-', 80)
< When {count} is zero or negative the result is empty.
When {expr} is a |List| or a |Blob| the result is {expr}
- concatenated {count} times. Example: >
- :let longlist = repeat(['a', 'b'], 3)
+ concatenated {count} times. Example: >vim
+ let longlist = repeat(['a', 'b'], 3)
< Results in ['a', 'b', 'a', 'b', 'a', 'b'].
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->repeat(count)
<
@@ -6155,7 +6312,7 @@ resolve({filename}) *resolve()* *E655*
current directory (provided the result is still a relative
path name) and also keeps a trailing path separator.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->resolve()
<
@@ -6164,10 +6321,11 @@ reverse({object}) *reverse()*
{object} can be a |List| or a |Blob|.
Returns {object}.
Returns zero if {object} is not a List or a Blob.
- If you want an object to remain unmodified make a copy first: >
- :let revlist = reverse(copy(mylist))
-< Can also be used as a |method|: >
+ If you want an object to remain unmodified make a copy first: >vim
+ let revlist = reverse(copy(mylist))
+< Can also be used as a |method|: >vim
mylist->reverse()
+<
round({expr}) *round()*
Round off {expr} to the nearest integral value and return it
@@ -6175,34 +6333,38 @@ round({expr}) *round()*
values, then use the larger one (away from zero).
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo round(0.456)
-< 0.0 >
+< 0.0 >vim
echo round(4.5)
-< 5.0 >
+< 5.0 >vim
echo round(-4.5)
< -5.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->round()
+<
rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()*
Sends {event} to {channel} via |RPC| and returns immediately.
If {channel} is 0, the event is broadcast to all channels.
- Example: >
- :au VimLeave call rpcnotify(0, "leaving")
+ Example: >vim
+ au VimLeave call rpcnotify(0, "leaving")
+<
rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()*
Sends a request to {channel} to invoke {method} via
|RPC| and blocks until a response is received.
- Example: >
- :let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
+ Example: >vim
+ let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
+<
rpcstart({prog} [, {argv}]) *rpcstart()*
- Deprecated. Replace >
- :let id = rpcstart('prog', ['arg1', 'arg2'])
-< with >
- :let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
+ Deprecated. Replace >vim
+ let id = rpcstart('prog', ['arg1', 'arg2'])
+< with >vim
+ let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
+<
rubyeval({expr}) *rubyeval()*
Evaluate Ruby expression {expr} and return its result
@@ -6214,8 +6376,9 @@ rubyeval({expr}) *rubyeval()*
Other objects are represented as strings resulted from their
"Object#to_s" method.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRubyExpr()->rubyeval()
+<
screenattr({row}, {col}) *screenattr()*
Like |screenchar()|, but return the attribute. This is a rather
@@ -6223,8 +6386,9 @@ screenattr({row}, {col}) *screenattr()*
attribute at other positions.
Returns -1 when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenattr(col)
+<
screenchar({row}, {col}) *screenchar()*
The result is a Number, which is the character at position
@@ -6236,8 +6400,9 @@ screenchar({row}, {col}) *screenchar()*
This is mainly to be used for testing.
Returns -1 when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenchar(col)
+<
screenchars({row}, {col}) *screenchars()*
The result is a List of Numbers. The first number is the same
@@ -6246,8 +6411,9 @@ screenchars({row}, {col}) *screenchars()*
This is mainly to be used for testing.
Returns an empty List when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenchars(col)
+<
screencol() *screencol()*
The result is a Number, which is the current screen column of
@@ -6258,7 +6424,7 @@ screencol() *screencol()*
in a command (e.g. ":echo screencol()") it will return the
column inside the command line, which is 1 when the command is
executed. To get the cursor position in the file use one of
- the following mappings: >
+ the following mappings: >vim
nnoremap <expr> GG ":echom " .. screencol() .. "\n"
nnoremap <silent> GG :echom screencol()<CR>
noremap GG <Cmd>echom screencol()<Cr>
@@ -6288,8 +6454,9 @@ screenpos({winid}, {lnum}, {col}) *screenpos()*
first character is returned, {col} is not used.
Returns an empty Dict if {winid} is invalid.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->screenpos(lnum, col)
+<
screenrow() *screenrow()*
The result is a Number, which is the current screen row of the
@@ -6307,7 +6474,7 @@ screenstring({row}, {col}) *screenstring()*
This is mainly to be used for testing.
Returns an empty String when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenstring(col)
<
@@ -6352,7 +6519,7 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()*
When the {stopline} argument is given then the search stops
after searching this line. This is useful to restrict the
- search to a range of lines. Examples: >
+ search to a range of lines. Examples: >vim
let match = search('(', 'b', line("w0"))
let end = search('END', '', line("w$"))
< When {stopline} is used and it is not zero this also implies
@@ -6383,24 +6550,24 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()*
The cursor will be positioned at the match, unless the 'n'
flag is used.
- Example (goes over all files in the argument list): >
- :let n = 1
- :while n <= argc() " loop over all files in arglist
- : exe "argument " .. n
- : " start at the last char in the file and wrap for the
- : " first search to find match at start of file
- : normal G$
- : let flags = "w"
- : while search("foo", flags) > 0
- : s/foo/bar/g
- : let flags = "W"
- : endwhile
- : update " write the file if modified
- : let n = n + 1
- :endwhile
-<
- Example for using some flags: >
- :echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
+ Example (goes over all files in the argument list): >vim
+ let n = 1
+ while n <= argc() " loop over all files in arglist
+ exe "argument " .. n
+ " start at the last char in the file and wrap for the
+ " first search to find match at start of file
+ normal G$
+ let flags = "w"
+ while search("foo", flags) > 0
+ s/foo/bar/g
+ let flags = "W"
+ endwhile
+ update " write the file if modified
+ let n = n + 1
+ endwhile
+<
+ Example for using some flags: >vim
+ echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
< This will search for the keywords "if", "else", and "endif"
under or after the cursor. Because of the 'p' flag, it
returns 1, 2, or 3 depending on which keyword is found, or 0
@@ -6412,8 +6579,9 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()*
without the 'e' flag if the cursor is on the "f" of "if".
The 'n' flag tells the function not to move the cursor.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPattern()->search()
+<
searchcount([{options}]) *searchcount()*
Get or update the last search count, like what is displayed
@@ -6440,7 +6608,7 @@ searchcount([{options}]) *searchcount()*
this function with `recompute: 0` . This sometimes returns
wrong information because |n| and |N|'s maximum count is 99.
If it exceeded 99 the result must be max count + 1 (100). If
- you want to get correct information, specify `recompute: 1`: >
+ you want to get correct information, specify `recompute: 1`: >vim
" result == maxcount + 1 (100) when many matches
let result = searchcount(#{recompute: 0})
@@ -6449,7 +6617,7 @@ searchcount([{options}]) *searchcount()*
" to 1)
let result = searchcount()
<
- The function is useful to add the count to 'statusline': >
+ The function is useful to add the count to 'statusline': >vim
function! LastSearchCount() abort
let result = searchcount(#{recompute: 0})
if empty(result)
@@ -6478,7 +6646,7 @@ searchcount([{options}]) *searchcount()*
" \ '%{v:hlsearch ? LastSearchCount() : ""}'
<
You can also update the search count, which can be useful in a
- |CursorMoved| or |CursorMovedI| autocommand: >
+ |CursorMoved| or |CursorMovedI| autocommand: >vim
autocmd CursorMoved,CursorMovedI *
\ let s:searchcount_timer = timer_start(
@@ -6492,7 +6660,7 @@ searchcount([{options}]) *searchcount()*
endfunction
<
This can also be used to count matched texts with specified
- pattern in the current buffer using "pattern": >
+ pattern in the current buffer using "pattern": >vim
" Count '\<foo\>' in this buffer
" (Note that it also updates search count)
@@ -6516,7 +6684,7 @@ searchcount([{options}]) *searchcount()*
and different with |@/|.
this works as same as the
below command is executed
- before calling this function >
+ before calling this function >vim
let @/ = pattern
< (default: |@/|)
timeout |Number| 0 or negative number is no
@@ -6536,7 +6704,7 @@ searchcount([{options}]) *searchcount()*
value. see |cursor()|, |getpos()|
(default: cursor's position)
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSearchOpts()->searchcount()
<
@@ -6553,12 +6721,12 @@ searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
Moves the cursor to the found match.
Returns zero for success, non-zero for failure.
- Example: >
+ Example: >vim
if searchdecl('myvar') == 0
echo getline('.')
endif
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->searchdecl()
<
@@ -6578,8 +6746,8 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeo
must not contain \( \) pairs. Use of \%( \) is allowed. When
{middle} is not empty, it is found when searching from either
direction, but only when not in a nested start-end pair. A
- typical use is: >
- searchpair('\<if\>', '\<else\>', '\<endif\>')
+ typical use is: >vim
+ echo searchpair('\<if\>', '\<else\>', '\<endif\>')
< By leaving {middle} empty the "else" is skipped.
{flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
@@ -6609,7 +6777,7 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeo
The search starts exactly at the cursor. A match with
{start}, {middle} or {end} at the next character, in the
- direction of searching, is the first one found. Example: >
+ direction of searching, is the first one found. Example: >vim
if 1
if 2
endif 2
@@ -6625,9 +6793,9 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeo
that when the cursor is inside a match with the end it finds
the matching start.
- Example, to find the "endif" command in a Vim script: >
+ Example, to find the "endif" command in a Vim script: >vim
- :echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
+ echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
\ 'getline(".") =~ "^\\s*\""')
< The cursor must be at or after the "if" for which a match is
@@ -6636,15 +6804,15 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeo
catches comments at the start of a line, not after a command.
Also, a word "en" or "if" halfway through a line is considered
a match.
- Another example, to search for the matching "{" of a "}": >
+ Another example, to search for the matching "{" of a "}": >vim
- :echo searchpair('{', '', '}', 'bW')
+ echo searchpair('{', '', '}', 'bW')
< This works when the cursor is at or before the "}" for which a
match is to be found. To reject matches that syntax
- highlighting recognized as strings: >
+ highlighting recognized as strings: >vim
- :echo searchpair('{', '', '}', 'bW',
+ echo searchpair('{', '', '}', 'bW',
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
<
@@ -6654,9 +6822,9 @@ searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {ti
column position of the match. The first element of the |List|
is the line number and the second element is the byte index of
the column position of the match. If no match is found,
- returns [0, 0]. >
+ returns [0, 0]. >vim
- :let [lnum,col] = searchpairpos('{', '', '}', 'n')
+ let [lnum,col] = searchpairpos('{', '', '}', 'n')
<
See |match-parens| for a bigger and more useful example.
@@ -6667,23 +6835,25 @@ searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
is the line number and the second element is the byte index of
the column position of the match. If no match is found,
returns [0, 0].
- Example: >
- :let [lnum, col] = searchpos('mypattern', 'n')
+ Example: >vim
+ let [lnum, col] = searchpos('mypattern', 'n')
< When the 'p' flag is given then there is an extra item with
- the sub-pattern match number |search()-sub-match|. Example: >
- :let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
+ the sub-pattern match number |search()-sub-match|. Example: >vim
+ let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
< In this example "submatch" is 2 when a lowercase letter is
found |/\l|, 3 when an uppercase letter is found |/\u|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPattern()->searchpos()
+<
serverlist() *serverlist()*
Returns a list of server addresses, or empty if all servers
were stopped. |serverstart()| |serverstop()|
- Example: >
- :echo serverlist()
+ Example: >vim
+ echo serverlist()
+<
serverstart([{address}]) *serverstart()*
Opens a socket or named pipe at {address} and listens for
@@ -6698,24 +6868,26 @@ serverstart([{address}]) *serverstart()*
assigns a random port).
- Else {address} is the path to a named pipe (except on Windows).
- If {address} has no slashes ("/") it is treated as the
- "name" part of a generated path in this format: >
+ "name" part of a generated path in this format: >vim
stdpath("run").."/{name}.{pid}.{counter}"
-< - If {address} is omitted the name is "nvim". >
- :echo serverstart()
+< - If {address} is omitted the name is "nvim". >vim
+ echo serverstart()
+< >
=> /tmp/nvim.bram/oknANW/nvim.15430.5
-
-< Example bash command to list all Nvim servers: >
+<
+ Example bash command to list all Nvim servers: >bash
ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
-< Example named pipe: >
+< Example named pipe: >vim
if has('win32')
echo serverstart('\\.\pipe\nvim-pipe-1234')
else
echo serverstart('nvim.sock')
endif
<
- Example TCP/IP address: >
+ Example TCP/IP address: >vim
echo serverstart('::1:12345')
+<
serverstop({address}) *serverstop()*
Closes the pipe or socket at {address}.
@@ -6748,8 +6920,9 @@ setbufline({buf}, {lnum}, {text}) *setbufline()*
error message is given.
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetText()->setbufline(buf, lnum)
+<
setbufvar({buf}, {varname}, {val}) *setbufvar()*
Set option or local variable {varname} in buffer {buf} to
@@ -6760,13 +6933,13 @@ setbufvar({buf}, {varname}, {val}) *setbufvar()*
For the use of {buf}, see |bufname()| above.
The {varname} argument is a string.
Note that the variable name without "b:" must be used.
- Examples: >
- :call setbufvar(1, "&mod", 1)
- :call setbufvar("todo", "myvar", "foobar")
+ Examples: >vim
+ call setbufvar(1, "&mod", 1)
+ call setbufvar("todo", "myvar", "foobar")
< This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->setbufvar(buf, varname)
<
@@ -6774,7 +6947,7 @@ setcellwidths({list}) *setcellwidths()*
Specify overrides for cell widths of character ranges. This
tells Vim how wide characters are when displayed in the
terminal, counted in screen cells. The values override
- 'ambiwidth'. Example: >
+ 'ambiwidth'. Example: >vim
call setcellwidths([
\ [0x111, 0x111, 1],
\ [0x2194, 0x2199, 2],
@@ -6795,7 +6968,7 @@ setcellwidths({list}) *setcellwidths()*
If the new value causes 'fillchars' or 'listchars' to become
invalid it is rejected and an error is given.
- To clear the overrides pass an empty {list}: >
+ To clear the overrides pass an empty {list}: >vim
call setcellwidths([])
< You can use the script $VIMRUNTIME/tools/emoji_list.vim to see
@@ -6809,14 +6982,15 @@ setcharpos({expr}, {list}) *setcharpos()*
character index instead of the byte index in the line.
Example:
- With the text "μ—¬λ³΄μ„Έμš”" in line 8: >
+ With the text "μ—¬λ³΄μ„Έμš”" in line 8: >vim
call setcharpos('.', [0, 8, 4, 0])
-< positions the cursor on the fourth character 'μš”'. >
+< positions the cursor on the fourth character 'μš”'. >vim
call setpos('.', [0, 8, 4, 0])
< positions the cursor on the second character '보'.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPosition()->setcharpos('.')
+<
setcharsearch({dict}) *setcharsearch()*
Set the current character search information to {dict},
@@ -6832,14 +7006,15 @@ setcharsearch({dict}) *setcharsearch()*
character search
This can be useful to save/restore a user's character search
- from a script: >
- :let prevsearch = getcharsearch()
- :" Perform a command which clobbers user's search
- :call setcharsearch(prevsearch)
+ from a script: >vim
+ let prevsearch = getcharsearch()
+ " Perform a command which clobbers user's search
+ call setcharsearch(prevsearch)
< Also see |getcharsearch()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
SavedSearch()->setcharsearch()
+<
setcmdline({str} [, {pos}]) *setcmdline()*
Set the command line to {str} and set the cursor position to
@@ -6848,8 +7023,9 @@ setcmdline({str} [, {pos}]) *setcmdline()*
Returns 0 when successful, 1 when not editing the command
line.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->setcmdline()
+<
setcmdpos({pos}) *setcmdpos()*
Set the cursor position in the command line to byte position
@@ -6866,8 +7042,9 @@ setcmdpos({pos}) *setcmdpos()*
Returns 0 when successful, 1 when not editing the command
line.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPos()->setcmdpos()
+<
setcursorcharpos({lnum}, {col} [, {off}])
setcursorcharpos({list}) *setcursorcharpos()*
@@ -6875,24 +7052,25 @@ setcursorcharpos({list}) *setcursorcharpos()*
character index instead of the byte index in the line.
Example:
- With the text "μ—¬λ³΄μ„Έμš”" in line 4: >
+ With the text "μ—¬λ³΄μ„Έμš”" in line 4: >vim
call setcursorcharpos(4, 3)
-< positions the cursor on the third character 'μ„Έ'. >
+< positions the cursor on the third character 'μ„Έ'. >vim
call cursor(4, 3)
< positions the cursor on the first character 'μ—¬'.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCursorPos()->setcursorcharpos()
+<
setenv({name}, {val}) *setenv()*
- Set environment variable {name} to {val}. Example: >
+ Set environment variable {name} to {val}. Example: >vim
call setenv('HOME', '/home/myhome')
< When {val} is |v:null| the environment variable is deleted.
See also |expr-env|.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetPath()->setenv('PATH')
<
@@ -6911,7 +7089,7 @@ setfperm({fname}, {mode}) *setfperm()* *chmod*
Returns non-zero for success, zero for failure.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->setfperm(mode)
<
To read permissions see |getfperm()|.
@@ -6930,22 +7108,23 @@ setline({lnum}, {text}) *setline()*
If this succeeds, FALSE is returned. If this fails (most likely
because {lnum} is invalid) TRUE is returned.
- Example: >
- :call setline(5, strftime("%c"))
+ Example: >vim
+ call setline(5, strftime("%c"))
< When {text} is a |List| then line {lnum} and following lines
- will be set to the items in the list. Example: >
- :call setline(5, ['aaa', 'bbb', 'ccc'])
-< This is equivalent to: >
- :for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
- : call setline(n, l)
- :endfor
+ will be set to the items in the list. Example: >vim
+ call setline(5, ['aaa', 'bbb', 'ccc'])
+< This is equivalent to: >vim
+ for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
+ call setline(n, l)
+ endfor
< Note: The '[ and '] marks are not set.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetText()->setline(lnum)
+<
setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
Create or replace or add to the location list for window {nr}.
@@ -6964,8 +7143,9 @@ setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
for the list of supported keys in {what}.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetLoclist()->setloclist(winnr)
+<
setmatches({list} [, {win}]) *setmatches()*
Restores a list of matches saved by |getmatches()| for the
@@ -6975,7 +7155,7 @@ setmatches({list} [, {win}]) *setmatches()*
If {win} is specified, use the window with this number or
window ID instead of the current window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMatches()->setmatches()
<
@@ -7028,8 +7208,9 @@ setpos({expr}, {list}) *setpos()*
also set the preferred column. Also see the "curswant" key in
|winrestview()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPosition()->setpos('.')
+<
setqflist({list} [, {action} [, {what}]]) *setqflist()*
Create or replace or add to the quickfix list.
@@ -7084,8 +7265,8 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()*
'r' The items from the current quickfix list are replaced
with the items from {list}. This can also be used to
- clear the list: >
- :call setqflist([], 'r')
+ clear the list: >vim
+ call setqflist([], 'r')
<
'f' All the quickfix lists in the quickfix stack are
freed.
@@ -7131,10 +7312,10 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()*
list is modified, "id" should be used instead of "nr" to
specify the list.
- Examples (See also |setqflist-examples|): >
- :call setqflist([], 'r', {'title': 'My search'})
- :call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
- :call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
+ Examples (See also |setqflist-examples|): >vim
+ call setqflist([], 'r', {'title': 'My search'})
+ call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
+ call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
<
Returns zero for success, -1 for failure.
@@ -7143,7 +7324,7 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()*
`:cc 1` to jump to the first position.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetErrorlist()->setqflist()
<
@@ -7179,33 +7360,34 @@ setreg({regname}, {value} [, {options}]) *setreg()*
set search and expression registers. Lists containing no
items act like empty strings.
- Examples: >
- :call setreg(v:register, @*)
- :call setreg('*', @%, 'ac')
- :call setreg('a', "1\n2\n3", 'b5')
- :call setreg('"', { 'points_to': 'a'})
+ Examples: >vim
+ call setreg(v:register, @*)
+ call setreg('*', @%, 'ac')
+ call setreg('a', "1\n2\n3", 'b5')
+ call setreg('"', { 'points_to': 'a'})
< This example shows using the functions to save and restore a
- register: >
- :let var_a = getreginfo()
- :call setreg('a', var_a)
-< or: >
- :let var_a = getreg('a', 1, 1)
- :let var_amode = getregtype('a')
- ....
- :call setreg('a', var_a, var_amode)
+ register: >vim
+ let var_a = getreginfo()
+ call setreg('a', var_a)
+< or: >vim
+ let var_a = getreg('a', 1, 1)
+ let var_amode = getregtype('a')
+ " ....
+ call setreg('a', var_a, var_amode)
< Note: you may not reliably restore register value
without using the third argument to |getreg()| as without it
newlines are represented as newlines AND Nul bytes are
represented as newlines as well, see |NL-used-for-Nul|.
You can also change the type of a register by appending
- nothing: >
- :call setreg('a', '', 'al')
+ nothing: >vim
+ call setreg('a', '', 'al')
< Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetText()->setreg('a')
+<
settabvar({tabnr}, {varname}, {val}) *settabvar()*
Set tab-local variable {varname} to {val} in tab page {tabnr}.
@@ -7216,8 +7398,9 @@ settabvar({tabnr}, {varname}, {val}) *settabvar()*
This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->settabvar(tab, name)
+<
settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
Set option or local variable {varname} in window {winnr} to
@@ -7230,14 +7413,15 @@ settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
doesn't work for a global or local buffer variable.
For a local buffer option the global value is unchanged.
Note that the variable name without "w:" must be used.
- Examples: >
- :call settabwinvar(1, 1, "&list", 0)
- :call settabwinvar(3, 2, "myvar", "foobar")
+ Examples: >vim
+ call settabwinvar(1, 1, "&list", 0)
+ call settabwinvar(3, 2, "myvar", "foobar")
< This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- fourth argument: >
+ fourth argument: >vim
GetValue()->settabwinvar(tab, winnr, name)
+<
settagstack({nr}, {dict} [, {action}]) *settagstack()*
Modify the tag stack of the window {nr} using {dict}.
@@ -7263,35 +7447,38 @@ settagstack({nr}, {dict} [, {action}]) *settagstack()*
Returns zero for success, -1 for failure.
Examples (for more examples see |tagstack-examples|):
- Empty the tag stack of window 3: >
+ Empty the tag stack of window 3: >vim
call settagstack(3, {'items' : []})
-< Save and restore the tag stack: >
+< Save and restore the tag stack: >vim
let stack = gettagstack(1003)
" do something else
call settagstack(1003, stack)
unlet stack
<
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetStack()->settagstack(winnr)
+<
setwinvar({nr}, {varname}, {val}) *setwinvar()*
Like |settabwinvar()| for the current tab page.
- Examples: >
- :call setwinvar(1, "&list", 0)
- :call setwinvar(2, "myvar", "foobar")
+ Examples: >vim
+ call setwinvar(1, "&list", 0)
+ call setwinvar(2, "myvar", "foobar")
< Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->setwinvar(winnr, name)
+<
sha256({string}) *sha256()*
Returns a String with 64 hex characters, which is the SHA256
checksum of {string}.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->sha256()
+<
shellescape({string} [, {special}]) *shellescape()*
Escape {string} for use as a shell command argument.
@@ -7317,21 +7504,22 @@ shellescape({string} [, {special}]) *shellescape()*
be escaped because in fish it is used as an escape character
inside single quotes.
- Example of use with a |:!| command: >
- :exe '!dir ' .. shellescape(expand('<cfile>'), 1)
+ Example of use with a |:!| command: >vim
+ exe '!dir ' .. shellescape(expand('<cfile>'), 1)
< This results in a directory listing for the file under the
- cursor. Example of use with |system()|: >
- :call system("chmod +w -- " .. shellescape(expand("%")))
+ cursor. Example of use with |system()|: >vim
+ call system("chmod +w -- " .. shellescape(expand("%")))
< See also |::S|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->shellescape()
+<
shiftwidth([{col}]) *shiftwidth()*
Returns the effective value of 'shiftwidth'. This is the
'shiftwidth' value unless it is zero, in which case it is the
'tabstop' value. To be backwards compatible in indent
- plugins, use this: >
+ plugins, use this: >vim
if exists('*shiftwidth')
func s:sw()
return shiftwidth()
@@ -7348,10 +7536,9 @@ shiftwidth([{col}]) *shiftwidth()*
'vartabstop' feature. If no {col} argument is given, column 1
will be assumed.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetColumn()->shiftwidth()
-
- sign_ functions are documented here: |sign-functions-details|
+<
sign_define({name} [, {dict}])
sign_define({list}) *sign_define()*
@@ -7387,7 +7574,7 @@ sign_define({list}) *sign_define()*
{list} is used, then returns a List of values one for each
defined sign.
- Examples: >
+ Examples: >vim
call sign_define("mySign", {
\ "text" : "=>",
\ "texthl" : "Error",
@@ -7399,8 +7586,9 @@ sign_define({list}) *sign_define()*
\ 'text' : '!!'}
\ ])
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignList()->sign_define()
+<
sign_getdefined([{name}]) *sign_getdefined()*
Get a list of defined signs and their attributes.
@@ -7430,15 +7618,16 @@ sign_getdefined([{name}]) *sign_getdefined()*
Returns an empty List if there are no signs and when {name} is
not found.
- Examples: >
+ Examples: >vim
" Get a list of all the defined signs
echo sign_getdefined()
" Get the attribute of the sign named mySign
echo sign_getdefined("mySign")
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignList()->sign_getdefined()
+<
sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
Return a list of signs placed in a buffer or all the buffers.
@@ -7479,7 +7668,7 @@ sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
Returns an empty list on failure or if there are no placed
signs.
- Examples: >
+ Examples: >vim
" Get a List of signs placed in eval.c in the
" global group
echo sign_getplaced("eval.c")
@@ -7500,7 +7689,7 @@ sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
" Get a List of all the placed signs
echo sign_getplaced()
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufname()->sign_getplaced()
<
@@ -7515,11 +7704,11 @@ sign_jump({id}, {group}, {buf}) *sign_jump()*
Returns the line number of the sign. Returns -1 if the
arguments are invalid.
- Example: >
+ Example: >vim
" Jump to sign 10 in the current buffer
call sign_jump(10, '', '')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignid()->sign_jump()
<
@@ -7552,7 +7741,7 @@ sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()*
Returns the sign identifier on success and -1 on failure.
- Examples: >
+ Examples: >vim
" Place a sign named sign1 with id 5 at line 20 in
" buffer json.c
call sign_place(5, '', 'sign1', 'json.c',
@@ -7571,7 +7760,7 @@ sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()*
call sign_place(10, 'g3', 'sign4', 'json.c',
\ {'lnum' : 40, 'priority' : 90})
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignid()->sign_place(group, name, expr)
<
@@ -7608,7 +7797,7 @@ sign_placelist({list}) *sign_placelist()*
Returns a List of sign identifiers. If failed to place a
sign, the corresponding list item is set to -1.
- Examples: >
+ Examples: >vim
" Place sign s1 with id 5 at line 20 and id 10 at line
" 30 in buffer a.c
let [n1, n2] = sign_placelist([
@@ -7633,8 +7822,9 @@ sign_placelist({list}) *sign_placelist()*
\ 'lnum' : 50}
\ ])
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignlist()->sign_placelist()
+<
sign_undefine([{name}])
sign_undefine({list}) *sign_undefine()*
@@ -7649,7 +7839,7 @@ sign_undefine({list}) *sign_undefine()*
{list} call, returns a list of values one for each undefined
sign.
- Examples: >
+ Examples: >vim
" Delete a sign named mySign
call sign_undefine("mySign")
@@ -7659,8 +7849,9 @@ sign_undefine({list}) *sign_undefine()*
" Delete all the signs
call sign_undefine()
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignlist()->sign_undefine()
+<
sign_unplace({group} [, {dict}]) *sign_unplace()*
Remove a previously placed sign in one or more buffers. This
@@ -7679,7 +7870,7 @@ sign_unplace({group} [, {dict}]) *sign_unplace()*
Returns 0 on success and -1 on failure.
- Examples: >
+ Examples: >vim
" Remove sign 10 from buffer a.vim
call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
@@ -7704,7 +7895,7 @@ sign_unplace({group} [, {dict}]) *sign_unplace()*
" Remove all the placed signs from all the buffers
call sign_unplace('*')
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetSigngroup()->sign_unplace()
<
@@ -7728,7 +7919,7 @@ sign_unplacelist({list}) *sign_unplacelist()*
Returns a List where an entry is set to 0 if the corresponding
sign was successfully removed or -1 on failure.
- Example: >
+ Example: >vim
" Remove sign with id 10 from buffer a.vim and sign
" with id 20 from buffer b.vim
call sign_unplacelist([
@@ -7736,7 +7927,7 @@ sign_unplacelist({list}) *sign_unplacelist()*
\ {'id' : 20, 'buffer' : 'b.vim'},
\ ])
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignlist()->sign_unplacelist()
<
@@ -7749,7 +7940,7 @@ simplify({filename}) *simplify()*
not removed either. On Unix "//path" is unchanged, but
"///path" is simplified to "/path" (this follows the Posix
standard).
- Example: >
+ Example: >vim
simplify("./dir/.././/file/") == "./file/"
< Note: The combination "dir/.." is only removed if "dir" is
a searchable directory or does not exist. On Unix, it is also
@@ -7757,35 +7948,38 @@ simplify({filename}) *simplify()*
directory. In order to resolve all the involved symbolic
links before simplifying the path name, use |resolve()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->simplify()
+<
sin({expr}) *sin()*
Return the sine of {expr}, measured in radians, as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo sin(100)
-< -0.506366 >
- :echo sin(-4.01)
+ Examples: >vim
+ echo sin(100)
+< -0.506366 >vim
+ echo sin(-4.01)
< 0.763301
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->sin()
+<
sinh({expr}) *sinh()*
Return the hyperbolic sine of {expr} as a |Float| in the range
[-inf, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo sinh(0.5)
-< 0.521095 >
- :echo sinh(-0.9)
+ Examples: >vim
+ echo sinh(0.5)
+< 0.521095 >vim
+ echo sinh(-0.9)
< -1.026517
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->sinh()
+<
slice({expr}, {start} [, {end}]) *slice()*
Similar to using a |slice| "expr[start : end]", but "end" is
@@ -7796,7 +7990,7 @@ slice({expr}, {start} [, {end}]) *slice()*
When {end} is -1 the last item is omitted.
Returns an empty value if {start} or {end} are invalid.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetList()->slice(offset)
<
@@ -7828,8 +8022,8 @@ sockconnect({mode}, {address} [, {opts}]) *sockconnect()*
sort({list} [, {func} [, {dict}]]) *sort()* *E702*
Sort the items in {list} in-place. Returns {list}.
- If you want a list to remain unmodified make a copy first: >
- :let sortedlist = sort(copy(mylist))
+ If you want a list to remain unmodified make a copy first: >vim
+ let sortedlist = sort(copy(mylist))
< When {func} is omitted, is empty or zero, then sort() uses the
string representation of each item to sort on. Numbers sort
@@ -7844,15 +8038,15 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
is used to compare strings. See |:language| check or set the
collation locale. |v:collate| can also be used to check the
current locale. Sorting using the locale typically ignores
- case. Example: >
+ case. Example: >vim
" ΓΆ is sorted similarly to o with English locale.
- :language collate en_US.UTF8
- :echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
+ language collate en_US.UTF8
+ echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
< ['n', 'o', 'O', 'ΓΆ', 'p', 'z'] ~
- >
+ >vim
" ΓΆ is sorted after z with Swedish locale.
- :language collate sv_SE.UTF8
- :echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
+ language collate sv_SE.UTF8
+ echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
< ['n', 'o', 'O', 'p', 'z', 'ΓΆ'] ~
This does not work properly on Mac.
@@ -7882,22 +8076,22 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
on numbers, text strings will sort next to each other, in the
same order as they were originally.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->sort()
< Also see |uniq()|.
- Example: >
+ Example: >vim
func MyCompare(i1, i2)
return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
endfunc
eval mylist->sort("MyCompare")
< A shorter compare version for this specific simple case, which
- ignores overflow: >
+ ignores overflow: >vim
func MyCompare(i1, i2)
return a:i1 - a:i2
endfunc
-< For a simple expression you can use a lambda: >
+< For a simple expression you can use a lambda: >vim
eval mylist->sort({i1, i2 -> i1 - i2})
<
@@ -7909,7 +8103,7 @@ soundfold({word}) *soundfold()*
This can be used for making spelling suggestions. Note that
the method can be quite slow.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWord()->soundfold()
<
@@ -7930,14 +8124,14 @@ spellbadword([{sentence}]) *spellbadword()*
"rare" rare word
"local" word only valid in another region
"caps" word should start with Capital
- Example: >
+ Example: >vim
echo spellbadword("the quik brown fox")
< ['quik', 'bad'] ~
The spelling information for the current window and the value
of 'spelllang' are used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->spellbadword()
<
@@ -7962,8 +8156,9 @@ spellsuggest({word} [, {max} [, {capital}]]) *spellsuggest()*
The spelling information for the current window is used. The
values of 'spelllang' and 'spellsuggest' are used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWord()->spellsuggest()
+<
split({string} [, {pattern} [, {keepempty}]]) *split()*
Make a |List| out of {string}. When {pattern} is omitted or
@@ -7976,20 +8171,23 @@ split({string} [, {pattern} [, {keepempty}]]) *split()*
{keepempty} argument is given and it's non-zero.
Other empty items are kept when {pattern} matches at least one
character or when {keepempty} is non-zero.
- Example: >
- :let words = split(getline('.'), '\W\+')
-< To split a string in individual characters: >
- :for c in split(mystring, '\zs')
+ Example: >vim
+ let words = split(getline('.'), '\W\+')
+< To split a string in individual characters: >vim
+ for c in split(mystring, '\zs') | endfor
< If you want to keep the separator you can also use '\zs' at
- the end of the pattern: >
- :echo split('abc:def:ghi', ':\zs')
-< ['abc:', 'def:', 'ghi'] ~
- Splitting a table where the first element can be empty: >
- :let items = split(line, ':', 1)
+ the end of the pattern: >vim
+ echo split('abc:def:ghi', ':\zs')
+< >
+ ['abc:', 'def:', 'ghi']
+<
+ Splitting a table where the first element can be empty: >vim
+ let items = split(line, ':', 1)
< The opposite function is |join()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->split()
+<
sqrt({expr}) *sqrt()*
Return the non-negative square root of Float {expr} as a
@@ -7997,15 +8195,16 @@ sqrt({expr}) *sqrt()*
{expr} must evaluate to a |Float| or a |Number|. When {expr}
is negative the result is NaN (Not a Number). Returns 0.0 if
{expr} is not a |Float| or a |Number|.
- Examples: >
- :echo sqrt(100)
-< 10.0 >
- :echo sqrt(-4.01)
+ Examples: >vim
+ echo sqrt(100)
+< 10.0 >vim
+ echo sqrt(-4.01)
< str2float("nan")
NaN may be different, it depends on system libraries.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->sqrt()
+<
srand([{expr}]) *srand()*
Initialize seed used by |rand()|:
@@ -8016,13 +8215,14 @@ srand([{expr}]) *srand()*
initialize the seed values. This is useful for testing or
when a predictable sequence is intended.
- Examples: >
- :let seed = srand()
- :let seed = srand(userinput)
- :echo rand(seed)
+ Examples: >vim
+ let seed = srand()
+ let seed = srand(userinput)
+ echo rand(seed)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
userinput->srand()
+<
stdioopen({opts}) *stdioopen()*
With |--headless| this opens stdin and stdout as a |channel|.
@@ -8063,8 +8263,8 @@ stdpath({what}) *stdpath()* *E6100*
state String Session state directory: storage for file
drafts, swap, undo, |shada|.
- Example: >
- :echo stdpath("config")
+ Example: >vim
+ echo stdpath("config")
<
str2float({string} [, {quoted}]) *str2float()*
@@ -8081,28 +8281,30 @@ str2float({string} [, {quoted}]) *str2float()*
The decimal point is always '.', no matter what the locale is
set to. A comma ends the number: "12,345.67" is converted to
12.0. You can strip out thousands separators with
- |substitute()|: >
+ |substitute()|: >vim
let f = str2float(substitute(text, ',', '', 'g'))
<
Returns 0.0 if the conversion fails.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let f = text->substitute(',', '', 'g')->str2float()
+<
str2list({string} [, {utf8}]) *str2list()*
Return a list containing the number values which represent
- each character in String {string}. Examples: >
- str2list(" ") returns [32]
- str2list("ABC") returns [65, 66, 67]
+ each character in String {string}. Examples: >vim
+ echo str2list(" ") " returns [32]
+ echo str2list("ABC") " returns [65, 66, 67]
< |list2str()| does the opposite.
UTF-8 encoding is always used, {utf8} option has no effect,
and exists only for backwards-compatibility.
- With UTF-8 composing characters are handled properly: >
- str2list("á") returns [97, 769]
+ With UTF-8 composing characters are handled properly: >vim
+ echo str2list("á") " returns [97, 769]
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetString()->str2list()
+<
str2nr({string} [, {base}]) *str2nr()*
Convert string {string} to a number.
@@ -8112,7 +8314,7 @@ str2nr({string} [, {base}]) *str2nr()*
When {base} is omitted base 10 is used. This also means that
a leading zero doesn't cause octal conversion to be used, as
- with the default String to Number conversion. Example: >
+ with the default String to Number conversion. Example: >vim
let nr = str2nr('0123')
<
When {base} is 16 a leading "0x" or "0X" is ignored. With a
@@ -8123,7 +8325,7 @@ str2nr({string} [, {base}]) *str2nr()*
Returns 0 if {string} is empty or on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->str2nr()
<
@@ -8137,7 +8339,7 @@ strcharlen({string}) *strcharlen()*
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strcharlen()
<
@@ -8150,13 +8352,13 @@ strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()*
similar to |slice()|.
When a character index is used where a character does not
exist it is omitted and counted as one character. For
- example: >
- strcharpart('abc', -1, 2)
+ example: >vim
+ echo strcharpart('abc', -1, 2)
< results in 'a'.
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strcharpart(5)
<
@@ -8173,7 +8375,7 @@ strchars({string} [, {skipcc}]) *strchars()*
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
{skipcc} is only available after 7.4.755. For backward
- compatibility, you can define a wrapper function: >
+ compatibility, you can define a wrapper function: >vim
if has("patch-7.4.755")
function s:strchars(str, skipcc)
return strchars(a:str, a:skipcc)
@@ -8188,8 +8390,9 @@ strchars({string} [, {skipcc}]) *strchars()*
endfunction
endif
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strchars()
+<
strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
@@ -8205,8 +8408,9 @@ strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
Returns zero on error.
Also see |strlen()|, |strwidth()| and |strchars()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strdisplaywidth()
+<
strftime({format} [, {time}]) *strftime()*
The result is a String, which is a formatted date and time, as
@@ -8217,16 +8421,17 @@ strftime({format} [, {time}]) *strftime()*
format. The maximum length of the result is 80 characters.
See also |localtime()|, |getftime()| and |strptime()|.
The language can be changed with the |:language| command.
- Examples: >
- :echo strftime("%c") Sun Apr 27 11:49:23 1997
- :echo strftime("%Y %b %d %X") 1997 Apr 27 11:53:25
- :echo strftime("%y%m%d %T") 970427 11:53:55
- :echo strftime("%H:%M") 11:55
- :echo strftime("%c", getftime("file.c"))
- Show mod time of file.c.
-
-< Can also be used as a |method|: >
+ Examples: >vim
+ echo strftime("%c") " Sun Apr 27 11:49:23 1997
+ echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
+ echo strftime("%y%m%d %T") " 970427 11:53:55
+ echo strftime("%H:%M") " 11:55
+ echo strftime("%c", getftime("file.c"))
+ " Show mod time of file.c.
+
+< Can also be used as a |method|: >vim
GetFormat()->strftime()
+<
strgetchar({str}, {index}) *strgetchar()*
Get a Number corresponding to the character at {index} in
@@ -8237,29 +8442,30 @@ strgetchar({str}, {index}) *strgetchar()*
Returns -1 if {index} is invalid.
Also see |strcharpart()| and |strchars()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strgetchar(5)
+<
stridx({haystack}, {needle} [, {start}]) *stridx()*
The result is a Number, which gives the byte index in
{haystack} of the first occurrence of the String {needle}.
If {start} is specified, the search starts at index {start}.
- This can be used to find a second match: >
- :let colon1 = stridx(line, ":")
- :let colon2 = stridx(line, ":", colon1 + 1)
+ This can be used to find a second match: >vim
+ let colon1 = stridx(line, ":")
+ let colon2 = stridx(line, ":", colon1 + 1)
< The search is done case-sensitive.
For pattern searches use |match()|.
-1 is returned if the {needle} does not occur in {haystack}.
See also |strridx()|.
- Examples: >
- :echo stridx("An Example", "Example") 3
- :echo stridx("Starting point", "Start") 0
- :echo stridx("Starting point", "start") -1
+ Examples: >vim
+ echo stridx("An Example", "Example") " 3
+ echo stridx("Starting point", "Start") " 0
+ echo stridx("Starting point", "start") " -1
< *strstr()* *strchr()*
stridx() works similar to the C function strstr(). When used
with a single character it works similar to strchr().
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHaystack()->stridx(needle)
<
@@ -8287,8 +8493,9 @@ string({expr}) *string()*
method, use |msgpackdump()| or |json_encode()| if you need to
share data with other application.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->string()
+<
strlen({string}) *strlen()*
The result is a Number, which is the length of the String
@@ -8299,8 +8506,9 @@ strlen({string}) *strlen()*
|strchars()|.
Also see |len()|, |strdisplaywidth()| and |strwidth()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->strlen()
+<
strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
The result is a String, which is part of {src}, starting from
@@ -8315,20 +8523,21 @@ strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
When bytes are selected which do not exist, this doesn't
result in an error, the bytes are simply omitted.
If {len} is missing, the copy continues from {start} till the
- end of the {src}. >
- strpart("abcdefg", 3, 2) == "de"
- strpart("abcdefg", -2, 4) == "ab"
- strpart("abcdefg", 5, 4) == "fg"
- strpart("abcdefg", 3) == "defg"
+ end of the {src}. >vim
+ echo strpart("abcdefg", 3, 2) " returns 'de'
+ echo strpart("abcdefg", -2, 4) " returns 'ab'
+ echo strpart("abcdefg", 5, 4) " returns 'fg'
+ echo strpart("abcdefg", 3) " returns 'defg'
< Note: To get the first character, {start} must be 0. For
- example, to get the character under the cursor: >
+ example, to get the character under the cursor: >vim
strpart(getline("."), col(".") - 1, 1, v:true)
<
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strpart(5)
+<
strptime({format}, {timestring}) *strptime()*
The result is a Number, which is a unix timestamp representing
@@ -8346,15 +8555,15 @@ strptime({format}, {timestring}) *strptime()*
result.
See also |strftime()|.
- Examples: >
- :echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
-< 862156163 >
- :echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
-< Sun Apr 27 11:53:55 1997 >
- :echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
+ Examples: >vim
+ echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
+< 862156163 >vim
+ echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
+< Sun Apr 27 11:53:55 1997 >vim
+ echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
< Sun Apr 27 12:53:55 1997
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFormat()->strptime(timestring)
<
@@ -8363,34 +8572,36 @@ strridx({haystack}, {needle} [, {start}]) *strridx()*
{haystack} of the last occurrence of the String {needle}.
When {start} is specified, matches beyond this index are
ignored. This can be used to find a match before a previous
- match: >
- :let lastcomma = strridx(line, ",")
- :let comma2 = strridx(line, ",", lastcomma - 1)
+ match: >vim
+ let lastcomma = strridx(line, ",")
+ let comma2 = strridx(line, ",", lastcomma - 1)
< The search is done case-sensitive.
For pattern searches use |match()|.
-1 is returned if the {needle} does not occur in {haystack}.
If the {needle} is empty the length of {haystack} is returned.
- See also |stridx()|. Examples: >
- :echo strridx("an angry armadillo", "an") 3
+ See also |stridx()|. Examples: >vim
+ echo strridx("an angry armadillo", "an") 3
< *strrchr()*
When used with a single character it works similar to the C
function strrchr().
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHaystack()->strridx(needle)
+<
strtrans({string}) *strtrans()*
The result is a String, which is {string} with all unprintable
characters translated into printable characters |'isprint'|.
- Like they are shown in a window. Example: >
+ Like they are shown in a window. Example: >vim
echo strtrans(@a)
< This displays a newline in register a as "^@" instead of
starting a new line.
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->strtrans()
+<
strutf16len({string} [, {countcc}]) *strutf16len()*
The result is a Number, which is the number of UTF-16 code
@@ -8404,14 +8615,14 @@ strutf16len({string} [, {countcc}]) *strutf16len()*
Returns zero on error.
Also see |strlen()| and |strcharlen()|.
- Examples: >
- echo strutf16len('a') returns 1
- echo strutf16len('Β©') returns 1
- echo strutf16len('😊') returns 2
- echo strutf16len('ą́') returns 1
- echo strutf16len('ą́', v:true) returns 3
-
- Can also be used as a |method|: >
+ Examples: >vim
+ echo strutf16len('a') " returns 1
+ echo strutf16len('Β©') " returns 1
+ echo strutf16len('😊') " returns 2
+ echo strutf16len('ą́') " returns 1
+ echo strutf16len('ą́', v:true) " returns 3
+
+ Can also be used as a |method|: >vim
GetText()->strutf16len()
<
@@ -8424,8 +8635,9 @@ strwidth({string}) *strwidth()*
Returns zero on error.
Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->strwidth()
+<
submatch({nr} [, {list}]) *submatch()* *E935*
Only for an expression in a |:substitute| command or
@@ -8449,14 +8661,15 @@ submatch({nr} [, {list}]) *submatch()* *E935*
Returns an empty string or list on error.
- Examples: >
- :s/\d\+/\=submatch(0) + 1/
- :echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
+ Examples: >vim
+ s/\d\+/\=submatch(0) + 1/
+ echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
< This finds the first number in the line and adds one to it.
A line break is included as a newline character.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetNr()->submatch()
+<
substitute({string}, {pat}, {sub}, {flags}) *substitute()*
The result is a String, which is a copy of {string}, in which
@@ -8480,36 +8693,37 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()*
When {pat} does not match in {string}, {string} is returned
unmodified.
- Example: >
- :let &path = substitute(&path, ",\\=[^,]*$", "", "")
-< This removes the last component of the 'path' option. >
- :echo substitute("testing", ".*", "\\U\\0", "")
+ Example: >vim
+ let &path = substitute(&path, ",\\=[^,]*$", "", "")
+< This removes the last component of the 'path' option. >vim
+ echo substitute("testing", ".*", "\\U\\0", "")
< results in "TESTING".
When {sub} starts with "\=", the remainder is interpreted as
- an expression. See |sub-replace-expression|. Example: >
- :echo substitute(s, '%\(\x\x\)',
+ an expression. See |sub-replace-expression|. Example: >vim
+ echo substitute(s, '%\(\x\x\)',
\ '\=nr2char("0x" .. submatch(1))', 'g')
< When {sub} is a Funcref that function is called, with one
- optional argument. Example: >
- :echo substitute(s, '%\(\x\x\)', SubNr, 'g')
+ optional argument. Example: >vim
+ echo substitute(s, '%\(\x\x\)', SubNr, 'g')
< The optional argument is a list which contains the whole
matched string and up to nine submatches, like what
- |submatch()| returns. Example: >
- :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
+ |submatch()| returns. Example: >vim
+ echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
< Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->substitute(pat, sub, flags)
+<
swapfilelist() *swapfilelist()*
Returns a list of swap file names, like what "vim -r" shows.
See the |-r| command argument. The 'directory' option is used
for the directories to inspect. If you only want to get a
list of swap files in the current directory then temporarily
- set 'directory' to a dot: >
+ set 'directory' to a dot: >vim
let save_dir = &directory
let &directory = '.'
let swapfiles = swapfilelist()
@@ -8533,8 +8747,9 @@ swapinfo({fname}) *swapinfo()*
Not a swap file: does not contain correct block ID
Magic number mismatch: Info in first block is invalid
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->swapinfo()
+<
swapname({buf}) *swapname()*
The result is the swap file path of the buffer {buf}.
@@ -8543,8 +8758,9 @@ swapname({buf}) *swapname()*
|:swapname| (unless there is no swap file).
If buffer {buf} has no swap file, returns an empty string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufname()->swapname()
+<
synID({lnum}, {col}, {trans}) *synID()*
The result is a Number, which is the syntax ID at the position
@@ -8568,8 +8784,8 @@ synID({lnum}, {col}, {trans}) *synID()*
Returns zero on error.
- Example (echoes the name of the syntax item under the cursor): >
- :echo synIDattr(synID(line("."), col("."), 1), "name")
+ Example (echoes the name of the syntax item under the cursor): >vim
+ echo synIDattr(synID(line("."), col("."), 1), "name")
<
synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
@@ -8611,11 +8827,12 @@ synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
Returns an empty string on error.
Example (echoes the color of the syntax item under the
- cursor): >
- :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
+ cursor): >vim
+ echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
+<
+ Can also be used as a |method|: >vim
+ echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
<
- Can also be used as a |method|: >
- :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
synIDtrans({synID}) *synIDtrans()*
The result is a Number, which is the translated syntax ID of
@@ -8625,8 +8842,9 @@ synIDtrans({synID}) *synIDtrans()*
Returns zero on error.
- Can also be used as a |method|: >
- :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
+ Can also be used as a |method|: >vim
+ echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
+<
synconcealed({lnum}, {col}) *synconcealed()*
The result is a |List| with currently three items:
@@ -8664,7 +8882,7 @@ synstack({lnum}, {col}) *synstack()*
returns, unless not the whole item is highlighted or it is a
transparent item.
This function is useful for debugging a syntax file.
- Example that shows the syntax stack under the cursor: >
+ Example that shows the syntax stack under the cursor: >vim
for id in synstack(line("."), col("."))
echo synIDattr(id, "name")
endfor
@@ -8680,8 +8898,8 @@ system({cmd} [, {input}]) *system()* *E677*
a |List|) and sets |v:shell_error| to the error code.
{cmd} is treated as in |jobstart()|:
If {cmd} is a List it runs directly (no 'shell').
- If {cmd} is a String it runs in the 'shell', like this: >
- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+ If {cmd} is a String it runs in the 'shell', like this: >vim
+ call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
< Not to be used for interactive commands.
@@ -8689,8 +8907,8 @@ system({cmd} [, {input}]) *system()* *E677*
- <CR><NL> is replaced with <NL>
- NUL characters are replaced with SOH (0x01)
- Example: >
- :echo system(['ls', expand('%:h')])
+ Example: >vim
+ echo system(['ls', expand('%:h')])
< If {input} is a string it is written to a pipe and passed as
stdin to the command. The string is written as-is, line
@@ -8704,8 +8922,8 @@ system({cmd} [, {input}]) *system()* *E677*
terminated by NL (and NUL where the text has NL).
*E5677*
Note: system() cannot write to or read from backgrounded ("&")
- shell commands, e.g.: >
- :echo system("cat - &", "foo")
+ shell commands, e.g.: >vim
+ echo system("cat - &", "foo")
< which is equivalent to: >
$ echo foo | bash -c 'cat - &'
< The pipes are disconnected (unless overridden by shell
@@ -8715,15 +8933,16 @@ system({cmd} [, {input}]) *system()* *E677*
Note: Use |shellescape()| or |::S| with |expand()| or
|fnamemodify()| to escape special characters in a command
argument. 'shellquote' and 'shellxquote' must be properly
- configured. Example: >
- :echo system('ls '..shellescape(expand('%:h')))
- :echo system('ls '..expand('%:h:S'))
+ configured. Example: >vim
+ echo system('ls '..shellescape(expand('%:h')))
+ echo system('ls '..expand('%:h:S'))
< Unlike ":!cmd" there is no automatic check for changed files.
Use |:checktime| to force a check.
- Can also be used as a |method|: >
- :echo GetCmd()->system()
+ Can also be used as a |method|: >vim
+ echo GetCmd()->system()
+<
systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
Same as |system()|, but returns a |List| with lines (parts of
@@ -8734,13 +8953,14 @@ systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
Note that on MS-Windows you may get trailing CR characters.
To see the difference between "echo hello" and "echo -n hello"
- use |system()| and |split()|: >
+ use |system()| and |split()|: >vim
echo split(system('echo hello'), '\n', 1)
<
Returns an empty string on error.
- Can also be used as a |method|: >
- :echo GetCmd()->systemlist()
+ Can also be used as a |method|: >vim
+ echo GetCmd()->systemlist()
+<
tabpagebuflist([{arg}]) *tabpagebuflist()*
The result is a |List|, where each item is the number of the
@@ -8748,15 +8968,16 @@ tabpagebuflist([{arg}]) *tabpagebuflist()*
{arg} specifies the number of the tab page to be used. When
omitted the current tab page is used.
When {arg} is invalid the number zero is returned.
- To get a list of all buffers in all tabs use this: >
+ To get a list of all buffers in all tabs use this: >vim
let buflist = []
for i in range(tabpagenr('$'))
call extend(buflist, tabpagebuflist(i + 1))
endfor
< Note that a buffer may appear in more than one window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabpage()->tabpagebuflist()
+<
tabpagenr([{arg}]) *tabpagenr()*
The result is a Number, which is the number of the current
@@ -8780,12 +9001,12 @@ tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
the window which will be used when going to this tab page.
- When "$" the number of windows is returned.
- When "#" the previous window nr is returned.
- Useful examples: >
+ Useful examples: >vim
tabpagewinnr(1) " current window of tab page 1
tabpagewinnr(4, '$') " number of windows in tab page 4
< When {tabarg} is invalid zero is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabpage()->tabpagewinnr()
<
@@ -8836,7 +9057,7 @@ taglist({expr} [, {filename}]) *taglist()*
located by Vim. Refer to |tags-file-format| for the format of
the tags file generated by the different ctags tools.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTagpattern()->taglist()
tan({expr}) *tan()*
@@ -8844,36 +9065,38 @@ tan({expr}) *tan()*
in the range [-inf, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo tan(10)
-< 0.648361 >
- :echo tan(-4.01)
+ Examples: >vim
+ echo tan(10)
+< 0.648361 >vim
+ echo tan(-4.01)
< -1.181502
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->tan()
+<
tanh({expr}) *tanh()*
Return the hyperbolic tangent of {expr} as a |Float| in the
range [-1, 1].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo tanh(0.5)
-< 0.462117 >
- :echo tanh(-1)
+ Examples: >vim
+ echo tanh(0.5)
+< 0.462117 >vim
+ echo tanh(-1)
< -0.761594
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->tanh()
<
tempname() *tempname()*
Generates a (non-existent) filename located in the Nvim root
|tempdir|. Scripts can use the filename as a temporary file.
- Example: >
- :let tmpfile = tempname()
- :exe "redir > " .. tmpfile
+ Example: >vim
+ let tmpfile = tempname()
+ exe "redir > " .. tmpfile
+<
termopen({cmd} [, {opts}]) *termopen()*
Spawns {cmd} in a new pseudo-terminal session connected
@@ -8905,7 +9128,7 @@ timer_info([{id}]) *timer_info()*
-1 means forever
"callback" the callback
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimer()->timer_info()
<
@@ -8922,7 +9145,7 @@ timer_pause({timer}, {paused}) *timer_pause()*
String, then the timer is paused, otherwise it is unpaused.
See |non-zero-arg|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimer()->timer_pause(1)
<
@@ -8948,7 +9171,7 @@ timer_start({time}, {callback} [, {options}]) *timer_start()* *timer*
Returns -1 on error.
- Example: >
+ Example: >vim
func MyHandler(timer)
echo 'Handler called'
endfunc
@@ -8956,7 +9179,7 @@ timer_start({time}, {callback} [, {options}]) *timer_start()* *timer*
\ {'repeat': 3})
< This invokes MyHandler() three times at 500 msec intervals.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMsec()->timer_start(callback)
< Not available in the |sandbox|.
@@ -8966,7 +9189,7 @@ timer_stop({timer}) *timer_stop()*
{timer} is an ID returned by timer_start(), thus it must be a
Number. If {timer} does not exist there is no error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimer()->timer_stop()
<
@@ -8980,16 +9203,18 @@ tolower({expr}) *tolower()*
characters turned into lowercase (just like applying |gu| to
the string). Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->tolower()
+<
toupper({expr}) *toupper()*
The result is a copy of the String given, with all lowercase
characters turned into uppercase (just like applying |gU| to
the string). Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->toupper()
+<
tr({src}, {fromstr}, {tostr}) *tr()*
The result is a copy of the {src} string with all characters
@@ -9001,14 +9226,15 @@ tr({src}, {fromstr}, {tostr}) *tr()*
Returns an empty string on error.
- Examples: >
+ Examples: >vim
echo tr("hello there", "ht", "HT")
-< returns "Hello THere" >
+< returns "Hello THere" >vim
echo tr("<blob>", "<>", "{}")
< returns "{blob}"
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->tr(from, to)
+<
trim({text} [, {mask} [, {dir}]]) *trim()*
Return {text} as a String where any character in {mask} is
@@ -9025,34 +9251,36 @@ trim({text} [, {mask} [, {dir}]]) *trim()*
This function deals with multibyte characters properly.
Returns an empty string on error.
- Examples: >
+ Examples: >vim
echo trim(" some text ")
-< returns "some text" >
+< returns "some text" >vim
echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
-< returns "RESERVE_TAIL" >
+< returns "RESERVE_TAIL" >vim
echo trim("rm<Xrm<>X>rrm", "rm<>")
-< returns "Xrm<>X" (characters in the middle are not removed) >
+< returns "Xrm<>X" (characters in the middle are not removed) >vim
echo trim(" vim ", " ", 2)
< returns " vim"
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->trim()
+<
trunc({expr}) *trunc()*
Return the largest integral value with magnitude less than or
equal to {expr} as a |Float| (truncate towards zero).
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo trunc(1.456)
-< 1.0 >
+< 1.0 >vim
echo trunc(-5.456)
-< -5.0 >
+< -5.0 >vim
echo trunc(4.0)
< 4.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->trunc()
+<
type({expr}) *type()*
The result is a Number representing the type of {expr}.
@@ -9067,22 +9295,23 @@ type({expr}) *type()*
Boolean: 6 (|v:true| and |v:false|)
Null: 7 (|v:null|)
Blob: 10 (|v:t_blob|)
- For backward compatibility, this method can be used: >
- :if type(myvar) == type(0)
- :if type(myvar) == type("")
- :if type(myvar) == type(function("tr"))
- :if type(myvar) == type([])
- :if type(myvar) == type({})
- :if type(myvar) == type(0.0)
- :if type(myvar) == type(v:true)
+ For backward compatibility, this method can be used: >vim
+ if type(myvar) == type(0) | endif
+ if type(myvar) == type("") | endif
+ if type(myvar) == type(function("tr")) | endif
+ if type(myvar) == type([]) | endif
+ if type(myvar) == type({}) | endif
+ if type(myvar) == type(0.0) | endif
+ if type(myvar) == type(v:true) | endif
< In place of checking for |v:null| type it is better to check
- for |v:null| directly as it is the only value of this type: >
- :if myvar is v:null
-< To check if the v:t_ variables exist use this: >
- :if exists('v:t_number')
+ for |v:null| directly as it is the only value of this type: >vim
+ if myvar is v:null | endif
+< To check if the v:t_ variables exist use this: >vim
+ if exists('v:t_number') | endif
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
mylist->type()
+<
undofile({name}) *undofile()*
Return the name of the undo file that would be used for a file
@@ -9095,8 +9324,9 @@ undofile({name}) *undofile()*
buffer without a file name will not write an undo file.
Useful in combination with |:wundo| and |:rundo|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->undofile()
+<
undotree() *undotree()*
Return the current state of the undo tree in a dictionary with
@@ -9144,14 +9374,14 @@ undotree() *undotree()*
uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
Remove second and succeeding copies of repeated adjacent
{list} items in-place. Returns {list}. If you want a list
- to remain unmodified make a copy first: >
- :let newlist = uniq(copy(mylist))
+ to remain unmodified make a copy first: >vim
+ let newlist = uniq(copy(mylist))
< The default compare function uses the string representation of
each item. For the use of {func} and {dict} see |sort()|.
Returns zero if {list} is not a |List|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->uniq()
<
@@ -9173,16 +9403,16 @@ utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) *utf16idx()*
from the UTF-16 index and |charidx()| for getting the
character index from the UTF-16 index.
Refer to |string-offset-encoding| for more information.
- Examples: >
- echo utf16idx('a😊😊', 3) returns 2
- echo utf16idx('a😊😊', 7) returns 4
- echo utf16idx('a😊😊', 1, 0, 1) returns 2
- echo utf16idx('a😊😊', 2, 0, 1) returns 4
- echo utf16idx('aą́c', 6) returns 2
- echo utf16idx('aą́c', 6, 1) returns 4
- echo utf16idx('a😊😊', 9) returns -1
-<
- Can also be used as a |method|: >
+ Examples: >vim
+ echo utf16idx('a😊😊', 3) " returns 2
+ echo utf16idx('a😊😊', 7) " returns 4
+ echo utf16idx('a😊😊', 1, 0, 1) " returns 2
+ echo utf16idx('a😊😊', 2, 0, 1) " returns 4
+ echo utf16idx('aą́c', 6) " returns 2
+ echo utf16idx('aą́c', 6, 1) " returns 4
+ echo utf16idx('a😊😊', 9) " returns -1
+<
+ Can also be used as a |method|: >vim
GetName()->utf16idx(idx)
<
@@ -9191,8 +9421,9 @@ values({dict}) *values()*
in arbitrary order. Also see |items()| and |keys()|.
Returns zero if {dict} is not a |Dict|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mydict->values()
+<
virtcol({expr} [, {list}]) *virtcol()*
The result is a Number, which is the screen column of the file
@@ -9231,23 +9462,24 @@ virtcol({expr} [, {list}]) *virtcol()*
character.
Note that only marks in the current file can be used.
- Examples: >
+ Examples: >vim
" With text "foo^Lbar" and cursor on the "^L":
- virtcol(".") " returns 5
- virtcol(".", 1) " returns [4, 5]
- virtcol("$") " returns 9
+ echo virtcol(".") " returns 5
+ echo virtcol(".", 1) " returns [4, 5]
+ echo virtcol("$") " returns 9
" With text " there", with 't at 'h':
- virtcol("'t") " returns 6
-< The first column is 1. 0 is returned for an error.
- A more advanced example that echoes the maximum length of
- all lines: >
+ echo virtcol("'t") " returns 6
+< Techo he first column is 1. 0 is returned for an error.
+ A echo more advanced example that echoes the maximum length of
+ all lines: >vim
echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetPos()->virtcol()
+<
virtcol2col({winid}, {lnum}, {col}) *virtcol2col()*
The result is a Number, which is the byte index of the
@@ -9266,8 +9498,9 @@ virtcol2col({winid}, {lnum}, {col}) *virtcol2col()*
See also |screenpos()|, |virtcol()| and |col()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->virtcol2col(lnum, col)
+<
visualmode([{expr}]) *visualmode()*
The result is a String, which describes the last Visual mode
@@ -9276,8 +9509,8 @@ visualmode([{expr}]) *visualmode()*
"V", or "<CTRL-V>" (a single CTRL-V character) for
character-wise, line-wise, or block-wise Visual mode
respectively.
- Example: >
- :exe "normal " .. visualmode()
+ Example: >vim
+ exe "normal " .. visualmode()
< This enters the same Visual mode as before. It is also useful
in scripts if you wish to act differently depending on the
Visual mode that was used.
@@ -9309,8 +9542,8 @@ wildmenumode() *wildmenumode()*
This can be used in mappings to handle the 'wildcharm' option
gracefully. (Makes only sense with |mapmode-c| mappings).
- For example to make <c-j> work like <down> in wildmode, use: >
- :cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
+ For example to make <c-j> work like <down> in wildmode, use: >vim
+ cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
<
(Note, this needs the 'wildcharm' option set appropriately).
@@ -9320,7 +9553,7 @@ win_execute({id}, {command} [, {silent}]) *win_execute()*
without triggering autocommands or changing directory. When
executing {command} autocommands will be triggered, this may
have unexpected side effects. Use `:noautocmd` if needed.
- Example: >
+ Example: >vim
call win_execute(winid, 'syntax enable')
< Doing the same with `setwinvar()` would not trigger
autocommands and not actually show syntax highlighting.
@@ -9329,15 +9562,17 @@ win_execute({id}, {command} [, {silent}]) *win_execute()*
an empty string is returned.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetCommand()->win_execute(winid)
+<
win_findbuf({bufnr}) *win_findbuf()*
Returns a |List| with |window-ID|s for windows that contain
buffer {bufnr}. When there is none the list is empty.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->win_findbuf()
+<
win_getid([{win} [, {tab}]]) *win_getid()*
Get the |window-ID| for the specified window.
@@ -9348,8 +9583,9 @@ win_getid([{win} [, {tab}]]) *win_getid()*
number {tab}. The first tab has number one.
Return zero if the window cannot be found.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->win_getid()
+<
win_gettype([{nr}]) *win_gettype()*
Return the type of the window:
@@ -9369,7 +9605,7 @@ win_gettype([{nr}]) *win_gettype()*
Also see the 'buftype' option.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_gettype()
<
@@ -9378,23 +9614,26 @@ win_gotoid({expr}) *win_gotoid()*
tabpage.
Return TRUE if successful, FALSE if the window cannot be found.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_gotoid()
+<
win_id2tabwin({expr}) *win_id2tabwin()*
Return a list with the tab number and window number of window
with ID {expr}: [tabnr, winnr].
Return [0, 0] if the window cannot be found.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_id2tabwin()
+<
win_id2win({expr}) *win_id2win()*
Return the window number of window with ID {expr}.
Return 0 if the window cannot be found in the current tabpage.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_id2win()
+<
win_move_separator({nr}, {offset}) *win_move_separator()*
Move window {nr}'s vertical separator (i.e., the right border)
@@ -9411,8 +9650,9 @@ win_move_separator({nr}, {offset}) *win_move_separator()*
window, since it has no separator on the right.
Only works for the current tab page. *E1308*
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->win_move_separator(offset)
+<
win_move_statusline({nr}, {offset}) *win_move_statusline()*
Move window {nr}'s status line (i.e., the bottom border) by
@@ -9426,8 +9666,9 @@ win_move_statusline({nr}, {offset}) *win_move_statusline()*
be found and FALSE otherwise.
Only works for the current tab page.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->win_move_statusline(offset)
+<
win_screenpos({nr}) *win_screenpos()*
Return the screen position of window {nr} as a list with two
@@ -9438,7 +9679,7 @@ win_screenpos({nr}) *win_screenpos()*
Returns [0, 0] if the window cannot be found in the current
tabpage.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_screenpos()
<
@@ -9462,7 +9703,7 @@ win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
present, the values of 'splitbelow' and
'splitright' are used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_splitmove(target)
<
@@ -9473,10 +9714,10 @@ winbufnr({nr}) *winbufnr()*
When {nr} is zero, the number of the buffer in the current
window is returned.
When window {nr} doesn't exist, -1 is returned.
- Example: >
- :echo "The file in the current window is " .. bufname(winbufnr(0))
+ Example: >vim
+ echo "The file in the current window is " .. bufname(winbufnr(0))
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
FindWindow()->winbufnr()->bufname()
<
@@ -9498,10 +9739,10 @@ winheight({nr}) *winheight()*
returned. When window {nr} doesn't exist, -1 is returned.
An existing window always has a height of zero or more.
This excludes any window toolbar line.
- Examples: >
- :echo "The current window has " .. winheight(0) .. " lines."
+ Examples: >vim
+ echo "The current window has " .. winheight(0) .. " lines."
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetWinid()->winheight()
<
@@ -9513,29 +9754,35 @@ winlayout([{tabnr}]) *winlayout()*
with number {tabnr}. If the tabpage {tabnr} is not found,
returns an empty list.
- For a leaf window, it returns:
+ For a leaf window, it returns: >
["leaf", {winid}]
+<
For horizontally split windows, which form a column, it
returns: >
["col", [{nested list of windows}]]
< For vertically split windows, which form a row, it returns: >
["row", [{nested list of windows}]]
<
- Example: >
+ Example: >vim
" Only one window in the tab page
- :echo winlayout()
+ echo winlayout()
+< >
['leaf', 1000]
+< >vim
" Two horizontally split windows
- :echo winlayout()
+ echo winlayout()
+< >
['col', [['leaf', 1000], ['leaf', 1001]]]
+< >vim
" The second tab page, with three horizontally split
" windows, with two vertically split windows in the
" middle window
- :echo winlayout(2)
+ echo winlayout(2)
+< >
['col', [['leaf', 1002], ['row', [['leaf', 1003],
['leaf', 1001]]], ['leaf', 1000]]]
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->winlayout()
<
@@ -9570,12 +9817,12 @@ winnr([{arg}]) *winnr()*
|:wincmd|.
When {arg} is invalid an error is given and zero is returned.
Also see |tabpagewinnr()| and |win_getid()|.
- Examples: >
+ Examples: >vim
let window_count = winnr('$')
let prev_window = winnr('#')
let wnum = winnr('3k')
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetWinval()->winnr()
<
@@ -9584,10 +9831,10 @@ winrestcmd() *winrestcmd()*
the current window sizes. Only works properly when no windows
are opened or closed and the current window and tab page is
unchanged.
- Example: >
- :let cmd = winrestcmd()
- :call MessWithWindowSizes()
- :exe cmd
+ Example: >vim
+ let cmd = winrestcmd()
+ call MessWithWindowSizes()
+ exe cmd
<
winrestview({dict}) *winrestview()*
@@ -9595,8 +9842,8 @@ winrestview({dict}) *winrestview()*
the view of the current window.
Note: The {dict} does not have to contain all values, that are
returned by |winsaveview()|. If values are missing, those
- settings won't be restored. So you can use: >
- :call winrestview({'curswant': 4})
+ settings won't be restored. So you can use: >vim
+ call winrestview({'curswant': 4})
<
This will only set the curswant value (the column the cursor
wants to move on vertical movements) of the cursor to column 5
@@ -9606,7 +9853,7 @@ winrestview({dict}) *winrestview()*
If you have changed the values the result is unpredictable.
If the window size changed the result won't be the same.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetView()->winrestview()
<
@@ -9643,16 +9890,17 @@ winwidth({nr}) *winwidth()*
When {nr} is zero, the width of the current window is
returned. When window {nr} doesn't exist, -1 is returned.
An existing window always has a width of zero or more.
- Examples: >
- :echo "The current window has " .. winwidth(0) .. " columns."
- :if winwidth(0) <= 50
- : 50 wincmd |
- :endif
+ Examples: >vim
+ echo "The current window has " .. winwidth(0) .. " columns."
+ if winwidth(0) <= 50
+ 50 wincmd |
+ endif
< For getting the terminal or screen size, see the 'columns'
option.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->winwidth()
+<
wordcount() *wordcount()*
The result is a dictionary of byte/chars/word statistics for
@@ -9692,13 +9940,13 @@ writefile({object}, {fname} [, {flags}]) *writefile()*
last list item. An empty item at the end does cause the
last line in the file to end in a NL.
- 'a' Append mode is used, lines are appended to the file: >
- :call writefile(["foo"], "event.log", "a")
- :call writefile(["bar"], "event.log", "a")
+ 'a' Append mode is used, lines are appended to the file: >vim
+ call writefile(["foo"], "event.log", "a")
+ call writefile(["bar"], "event.log", "a")
<
'D' Delete the file when the current function ends. This
- works like: >
- :defer delete({fname})
+ works like: >vim
+ defer delete({fname})
< Fails when not in a function. Also see |:defer|.
's' fsync() is called after writing the file. This flushes
@@ -9717,22 +9965,23 @@ writefile({object}, {fname} [, {flags}]) *writefile()*
fails.
Also see |readfile()|.
- To copy a file byte for byte: >
- :let fl = readfile("foo", "b")
- :call writefile(fl, "foocopy", "b")
+ To copy a file byte for byte: >vim
+ let fl = readfile("foo", "b")
+ call writefile(fl, "foocopy", "b")
-< Can also be used as a |method|: >
+< Can also be used as a |method|: >vim
GetText()->writefile("thefile")
+<
xor({expr}, {expr}) *xor()*
Bitwise XOR on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see `and()` and `or()`.
- Example: >
- :let bits = xor(bits, 0x80)
+ Example: >vim
+ let bits = xor(bits, 0x80)
<
- Can also be used as a |method|: >
- :let bits = bits->xor(0x80)
+ Can also be used as a |method|: >vim
+ let bits = bits->xor(0x80)
<
==============================================================================
@@ -9744,14 +9993,14 @@ pattern is used to find a match in a String, almost everything works in the
same way. The difference is that a String is handled like it is one line.
When it contains a "\n" character, this is not seen as a line break for the
pattern. It can be matched with a "\n" in the pattern, or with ".". Example:
->
- :let a = "aaaa\nxxxx"
- :echo matchstr(a, "..\n..")
- aa
- xx
- :echo matchstr(a, "a.x")
- a
- x
+>vim
+ let a = "aaaa\nxxxx"
+ echo matchstr(a, "..\n..")
+ " aa
+ " xx
+ echo matchstr(a, "a.x")
+ " a
+ " x
Don't forget that "^" will only match at the first character of the String and
"$" at the last character of the string. They don't match after or before a
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 82213324e3..8b56d8e708 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -6,16 +6,17 @@
--- a |Float| abs() returns a |Float|. When {expr} can be
--- converted to a |Number| abs() returns a |Number|. Otherwise
--- abs() gives an error message and returns -1.
---- Examples: >
+--- Examples: >vim
--- echo abs(1.456)
---- < 1.456 >
+--- < 1.456 >vim
--- echo abs(-5.456)
---- < 5.456 >
+--- < 5.456 >vim
--- echo abs(-4)
--- < 4
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->abs()
+--- <
---
--- @param expr any
--- @return number
@@ -27,31 +28,33 @@ function vim.fn.abs(expr) end
--- [-1, 1].
--- Returns NaN if {expr} is outside the range [-1, 1]. Returns
--- 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo acos(0)
---- < 1.570796 >
---- :echo acos(-0.5)
+--- Examples: >vim
+--- echo acos(0)
+--- < 1.570796 >vim
+--- echo acos(-0.5)
--- < 2.094395
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->acos()
+--- <
---
--- @param expr any
--- @return number
function vim.fn.acos(expr) end
--- Append the item {expr} to |List| or |Blob| {object}. Returns
---- the resulting |List| or |Blob|. Examples: >
---- :let alist = add([1, 2, 3], item)
---- :call add(mylist, "woodstock")
+--- the resulting |List| or |Blob|. Examples: >vim
+--- let alist = add([1, 2, 3], item)
+--- call add(mylist, "woodstock")
--- <Note that when {expr} is a |List| it is appended as a single
--- item. Use |extend()| to concatenate |Lists|.
--- When {object} is a |Blob| then {expr} must be a number.
--- Use |insert()| to add an item at another position.
--- Returns 1 if {object} is not a |List| or a |Blob|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->add(val1)->add(val2)
+--- <
---
--- @param object any
--- @param expr any
@@ -61,10 +64,11 @@ function vim.fn.add(object, expr) end
--- Bitwise AND on the two arguments. The arguments are converted
--- to a number. A List, Dict or Float argument causes an error.
--- Also see `or()` and `xor()`.
---- Example: >
---- :let flag = and(bits, 0x80)
---- <Can also be used as a |method|: >
---- :let flag = bits->and(0x80)
+--- Example: >vim
+--- let flag = and(bits, 0x80)
+--- <Can also be used as a |method|: >vim
+--- let flag = bits->and(0x80)
+--- <
---
--- @param expr any
--- @param expr1 any
@@ -73,8 +77,9 @@ vim.fn['and'] = function(expr, expr1) end
--- Returns Dictionary of |api-metadata|.
---
---- View it in a nice human-readable format: >
---- :lua vim.print(vim.fn.api_info())
+--- View it in a nice human-readable format: >vim
+--- lua vim.print(vim.fn.api_info())
+--- <
---
--- @return table
function vim.fn.api_info() end
@@ -87,12 +92,13 @@ function vim.fn.api_info() end
--- {lnum} can be zero to insert a line before the first one.
--- {lnum} is used like with |getline()|.
--- Returns 1 for failure ({lnum} out of range or out of memory),
---- 0 for success. Example: >
---- :let failed = append(line('$'), "# THE END")
---- :let failed = append(0, ["Chapter 1", "the beginning"])
+--- 0 for success. Example: >vim
+--- let failed = append(line('$'), "# THE END")
+--- let failed = append(0, ["Chapter 1", "the beginning"])
---
---- <Can also be used as a |method| after a List: >
+--- <Can also be used as a |method| after a List: >vim
--- mylist->append(lnum)
+--- <
---
--- @param lnum integer
--- @param text any
@@ -114,11 +120,12 @@ function vim.fn.append(lnum, text) end
--- On success 0 is returned, on failure 1 is returned.
---
--- If {buf} is not a valid buffer or {lnum} is not valid, an
---- error message is given. Example: >
---- :let failed = appendbufline(13, 0, "# THE START")
+--- error message is given. Example: >vim
+--- let failed = appendbufline(13, 0, "# THE START")
--- <
---- Can also be used as a |method| after a List: >
+--- Can also be used as a |method| after a List: >vim
--- mylist->appendbufline(buf, lnum)
+--- <
---
--- @param buf any
--- @param lnum integer
@@ -162,13 +169,13 @@ function vim.fn.argidx() end
function vim.fn.arglistid(winnr, tabnr) end
--- The result is the {nr}th file in the argument list. See
---- |arglist|. "argv(0)" is the first one. Example: >
---- :let i = 0
---- :while i < argc()
---- : let f = escape(fnameescape(argv(i)), '.')
---- : exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
---- : let i = i + 1
---- :endwhile
+--- |arglist|. "argv(0)" is the first one. Example: >vim
+--- let i = 0
+--- while i < argc()
+--- let f = escape(fnameescape(argv(i)), '.')
+--- exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
+--- let i = i + 1
+--- endwhile
--- <Without the {nr} argument, or when {nr} is -1, a |List| with
--- the whole |arglist| is returned.
---
@@ -190,13 +197,13 @@ function vim.fn.argv(nr, winid) end
--- [-1, 1].
--- Returns NaN if {expr} is outside the range [-1, 1]. Returns
--- 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo asin(0.8)
---- < 0.927295 >
---- :echo asin(-0.5)
+--- Examples: >vim
+--- echo asin(0.8)
+--- < 0.927295 >vim
+--- echo asin(-0.5)
--- < -0.523599
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->asin()
--- <
---
@@ -209,7 +216,7 @@ function vim.fn.asin(expr) end
--- Also see |assert_fails()|, |assert_nobeep()| and
--- |assert-return|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCmd()->assert_beeps()
--- <
---
@@ -227,13 +234,14 @@ function vim.fn.assert_beeps(cmd) end
--- from the Number 4. And the number 4 is different from the
--- Float 4.0. The value of 'ignorecase' is not used here, case
--- always matters.
---- Example: >
+--- Example: >vim
--- assert_equal('foo', 'bar')
--- <Will result in a string to be added to |v:errors|:
--- test.vim line 12: Expected 'foo' but got 'bar' ~
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->assert_equal([1, 2, 3])
+--- <
---
--- @param expected any
--- @param actual any
@@ -247,8 +255,9 @@ function vim.fn.assert_equal(expected, actual, msg) end
--- When {fname-one} or {fname-two} does not exist the error will
--- mention that.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLog()->assert_equalfile('expected.log')
+--- <
---
--- @return 0|1
function vim.fn.assert_equalfile() end
@@ -257,7 +266,7 @@ function vim.fn.assert_equalfile() end
--- message is added to |v:errors|. Also see |assert-return|.
--- This can be used to assert that a command throws an exception.
--- Using the error number, followed by a colon, avoids problems
---- with translations: >
+--- with translations: >vim
--- try
--- commandthatfails
--- call assert_false(1, 'command should have failed')
@@ -277,16 +286,16 @@ function vim.fn.assert_exception(error, msg) end
---
--- When {error} is a string it must be found literally in the
--- first reported error. Most often this will be the error code,
---- including the colon, e.g. "E123:". >
+--- including the colon, e.g. "E123:". >vim
--- assert_fails('bad cmd', 'E987:')
--- <
--- When {error} is a |List| with one or two strings, these are
--- used as patterns. The first pattern is matched against the
---- first reported error: >
+--- first reported error: >vim
--- assert_fails('cmd', ['E987:.*expected bool'])
--- <The second pattern, if present, is matched against the last
--- reported error. To only match the last error use an empty
---- string for the first error: >
+--- string for the first error: >vim
--- assert_fails('cmd', ['', 'E987:'])
--- <
--- If {msg} is empty then it is not used. Do this to get the
@@ -304,8 +313,9 @@ function vim.fn.assert_exception(error, msg) end
--- Note that beeping is not considered an error, and some failing
--- commands only beep. Use |assert_beeps()| for those.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCmd()->assert_fails('E99:')
+--- <
---
--- @param cmd any
--- @param error? any
@@ -324,8 +334,9 @@ function vim.fn.assert_fails(cmd, error, msg, lnum, context) end
--- A value is false when it is zero. When {actual} is not a
--- number the assert fails.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetResult()->assert_false()
+--- <
---
--- @param actual any
--- @param msg? any
@@ -359,12 +370,12 @@ function vim.fn.assert_inrange(lower, upper, actual, msg) end
--- Use "^" and "$" to match with the start and end of the text.
--- Use both to match the whole text.
---
---- Example: >
+--- Example: >vim
--- assert_match('^f.*o$', 'foobar')
--- <Will result in a string to be added to |v:errors|:
--- test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- getFile()->assert_match('foo.*')
--- <
---
@@ -378,7 +389,7 @@ function vim.fn.assert_match(pattern, actual, msg) end
--- produces a beep or visual bell.
--- Also see |assert_beeps()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCmd()->assert_nobeep()
--- <
---
@@ -390,9 +401,8 @@ function vim.fn.assert_nobeep(cmd) end
--- |v:errors| when {expected} and {actual} are equal.
--- Also see |assert-return|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->assert_notequal([1, 2, 3])
----
--- <
---
--- @param expected any
@@ -405,7 +415,7 @@ function vim.fn.assert_notequal(expected, actual, msg) end
--- |v:errors| when {pattern} matches {actual}.
--- Also see |assert-return|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- getFile()->assert_notmatch('bar.*')
--- <
---
@@ -418,7 +428,7 @@ function vim.fn.assert_notmatch(pattern, actual, msg) end
--- Report a test failure directly, using String {msg}.
--- Always returns one.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMessage()->assert_report()
--- <
---
@@ -433,7 +443,7 @@ function vim.fn.assert_report(msg) end
--- When {actual} is not a number or |v:true| the assert fails.
--- When {msg} is given it precedes the default message.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetResult()->assert_true()
--- <
---
@@ -446,14 +456,15 @@ function vim.fn.assert_true(actual, msg) end
--- the range [-pi/2, +pi/2] radians, as a |Float|.
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo atan(100)
---- < 1.560797 >
---- :echo atan(-4.01)
+--- Examples: >vim
+--- echo atan(100)
+--- < 1.560797 >vim
+--- echo atan(-4.01)
--- < -1.326405
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->atan()
+--- <
---
--- @param expr any
--- @return number
@@ -464,14 +475,15 @@ function vim.fn.atan(expr) end
--- {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
--- |Number|.
---- Examples: >
---- :echo atan2(-1, 1)
---- < -0.785398 >
---- :echo atan2(1, -1)
+--- Examples: >vim
+--- echo atan2(-1, 1)
+--- < -0.785398 >vim
+--- echo atan2(1, -1)
--- < 2.356194
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->atan2(1)
+--- <
---
--- @param expr1 any
--- @param expr2 any
@@ -479,13 +491,13 @@ function vim.fn.atan(expr) end
function vim.fn.atan2(expr1, expr2) end
--- Return a List containing the number value of each byte in Blob
---- {blob}. Examples: >
---- blob2list(0z0102.0304) returns [1, 2, 3, 4]
---- blob2list(0z) returns []
+--- {blob}. Examples: >vim
+--- blob2list(0z0102.0304) " returns [1, 2, 3, 4]
+--- blob2list(0z) " returns []
--- <Returns an empty List on error. |list2blob()| does the
--- opposite.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBlob()->blob2list()
--- <
---
@@ -533,13 +545,14 @@ function vim.fn.browsedir(title, initdir) end
--- created buffer. When {name} is an empty string then a new
--- buffer is always created.
--- The buffer will not have 'buflisted' set and not be loaded
---- yet. To add some text to the buffer use this: >
+--- yet. To add some text to the buffer use this: >vim
--- let bufnr = bufadd('someName')
--- call bufload(bufnr)
--- call setbufline(bufnr, 1, ['some', 'text'])
--- <Returns 0 on error.
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- let bufnr = 'somename'->bufadd()
+--- <
---
--- @param name string
--- @return integer
@@ -566,8 +579,9 @@ function vim.fn.bufadd(name) end
--- Use "bufexists(0)" to test for the existence of an alternate
--- file name.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- let exists = 'somename'->bufexists()
+--- <
---
--- @param buf any
--- @return 0|1
@@ -598,8 +612,9 @@ function vim.fn.buffer_number(...) end
--- {buf} exists and is listed (has the 'buflisted' option set).
--- The {buf} argument is used like with |bufexists()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- let listed = 'somename'->buflisted()
+--- <
---
--- @param buf any
--- @return 0|1
@@ -614,8 +629,9 @@ function vim.fn.buflisted(buf) end
--- there will be no dialog, the buffer will be loaded anyway.
--- The {buf} argument is used like with |bufexists()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- eval 'somename'->bufload()
+--- <
---
--- @param buf any
function vim.fn.bufload(buf) end
@@ -624,8 +640,9 @@ function vim.fn.bufload(buf) end
--- {buf} exists and is loaded (shown in a window or hidden).
--- The {buf} argument is used like with |bufexists()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- let loaded = 'somename'->bufloaded()
+--- <
---
--- @param buf any
--- @return 0|1
@@ -651,17 +668,17 @@ function vim.fn.bufloaded(buf) end
--- with a listed buffer, that one is returned. Next unlisted
--- buffers are searched for.
--- If the {buf} is a String, but you want to use it as a buffer
---- number, force it to be a Number by adding zero to it: >
---- :echo bufname("3" + 0)
---- <Can also be used as a |method|: >
+--- number, force it to be a Number by adding zero to it: >vim
+--- echo bufname("3" + 0)
+--- <Can also be used as a |method|: >vim
--- echo bufnr->bufname()
---
--- <If the buffer doesn't exist, or doesn't have a name, an empty
---- string is returned. >
---- bufname("#") alternate buffer name
---- bufname(3) name of buffer 3
---- bufname("%") name of current buffer
---- bufname("file2") name of buffer where "file2" matches.
+--- string is returned. >vim
+--- echo bufname("#") " alternate buffer name
+--- echo bufname(3) " name of buffer 3
+--- echo bufname("%") " name of current buffer
+--- echo bufname("file2") " name of buffer where "file2" matches.
--- <
---
--- @param buf? any
@@ -674,15 +691,16 @@ function vim.fn.bufname(buf) end
--- If the buffer doesn't exist, -1 is returned. Or, if the
--- {create} argument is present and TRUE, a new, unlisted,
--- buffer is created and its number is returned.
---- bufnr("$") is the last buffer: >
---- :let last_buffer = bufnr("$")
+--- bufnr("$") is the last buffer: >vim
+--- let last_buffer = bufnr("$")
--- <The result is a Number, which is the highest buffer number
--- of existing buffers. Note that not all buffers with a smaller
--- number necessarily exist, because ":bwipeout" may have removed
--- them. Use bufexists() to test for the existence of a buffer.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- echo bufref->bufnr()
+--- <
---
--- @param buf? any
--- @param create? any
@@ -692,15 +710,16 @@ function vim.fn.bufnr(buf, create) end
--- The result is a Number, which is the |window-ID| of the first
--- window associated with buffer {buf}. For the use of {buf},
--- see |bufname()| above. If buffer {buf} doesn't exist or
---- there is no such window, -1 is returned. Example: >
+--- there is no such window, -1 is returned. Example: >vim
---
--- echo "A window containing buffer 1 is " .. (bufwinid(1))
--- <
--- Only deals with the current tab page. See |win_findbuf()| for
--- finding more.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- FindBuffer()->bufwinid()
+--- <
---
--- @param buf any
--- @return integer
@@ -709,15 +728,16 @@ function vim.fn.bufwinid(buf) end
--- Like |bufwinid()| but return the window number instead of the
--- |window-ID|.
--- If buffer {buf} doesn't exist or there is no such window, -1
---- is returned. Example: >
+--- is returned. Example: >vim
---
--- echo "A window containing buffer 1 is " .. (bufwinnr(1))
---
--- <The number can be used with |CTRL-W_w| and ":wincmd w"
--- |:wincmd|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- FindBuffer()->bufwinnr()
+--- <
---
--- @param buf any
--- @return integer
@@ -732,8 +752,9 @@ function vim.fn.bufwinnr(buf) end
---
--- Returns -1 if the {byte} value is invalid.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetOffset()->byte2line()
+--- <
---
--- @param byte any
--- @return integer
@@ -755,10 +776,10 @@ function vim.fn.byte2line(byte) end
--- middle of a character (e.g. in a 4-byte character), then the
--- byte index of the first byte in the character is returned.
--- Refer to |string-offset-encoding| for more information.
---- Example : >
+--- Example : >vim
--- echo matchstr(str, ".", byteidx(str, 3))
--- <will display the fourth character. Another way to do the
---- same: >
+--- same: >vim
--- let s = strpart(str, byteidx(str, 3))
--- echo strpart(s, 0, byteidx(s, 1))
--- <Also see |strgetchar()| and |strcharpart()|.
@@ -768,13 +789,14 @@ function vim.fn.byte2line(byte) end
--- in bytes is returned.
--- See |charidx()| and |utf16idx()| for getting the character and
--- UTF-16 index respectively from the byte index.
---- Examples: >
---- echo byteidx('a😊😊', 2) returns 5
---- echo byteidx('a😊😊', 2, 1) returns 1
---- echo byteidx('a😊😊', 3, 1) returns 5
+--- Examples: >vim
+--- echo byteidx('a😊😊', 2) " returns 5
+--- echo byteidx('a😊😊', 2, 1) " returns 1
+--- echo byteidx('a😊😊', 3, 1) " returns 5
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->byteidx(idx)
+--- <
---
--- @param expr any
--- @param nr integer
@@ -783,7 +805,7 @@ function vim.fn.byte2line(byte) end
function vim.fn.byteidx(expr, nr, utf16) end
--- Like byteidx(), except that a composing character is counted
---- as a separate character. Example: >
+--- as a separate character. Example: >vim
--- let s = 'e' .. nr2char(0x301)
--- echo byteidx(s, 1)
--- echo byteidxcomp(s, 1)
@@ -792,8 +814,9 @@ function vim.fn.byteidx(expr, nr, utf16) end
--- character is 3 bytes), the second echo results in 1 ('e' is
--- one byte).
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->byteidxcomp(idx)
+--- <
---
--- @param expr any
--- @param nr integer
@@ -809,7 +832,7 @@ function vim.fn.byteidxcomp(expr, nr, utf16) end
--- {dict} is for functions with the "dict" attribute. It will be
--- used to set the local variable "self". |Dictionary-function|
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFunc()->call([arg, arg], dict)
--- <
---
@@ -822,17 +845,17 @@ function vim.fn.call(func, arglist, dict) end
--- Return the smallest integral value greater than or equal to
--- {expr} as a |Float| (round up).
--- {expr} must evaluate to a |Float| or a |Number|.
---- Examples: >
+--- Examples: >vim
--- echo ceil(1.456)
---- < 2.0 >
+--- < 2.0 >vim
--- echo ceil(-5.456)
---- < -5.0 >
+--- < -5.0 >vim
--- echo ceil(4.0)
--- < 4.0
---
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->ceil()
--- <
---
@@ -874,8 +897,8 @@ function vim.fn.changenr() end
--- {data} may be a string, string convertible, |Blob|, or a list.
--- If {data} is a list, the items will be joined by newlines; any
--- newlines in an item will be sent as NUL. To send a final
---- newline, include a final empty string. Example: >
---- :call chansend(id, ["abc", "123\n456", ""])
+--- newline, include a final empty string. Example: >vim
+--- call chansend(id, ["abc", "123\n456", ""])
--- <will send "abc<NL>123<NUL>456<NL>".
---
--- chansend() writes raw data, not RPC messages. If the channel
@@ -888,12 +911,12 @@ function vim.fn.changenr() end
function vim.fn.chansend(id, data) end
--- Return Number value of the first char in {string}.
---- Examples: >
---- char2nr(" ") returns 32
---- char2nr("ABC") returns 65
---- char2nr("Γ‘") returns 225
---- char2nr("Γ‘"[0]) returns 195
---- char2nr("\<M-x>") returns 128
+--- Examples: >vim
+--- echo char2nr(" ") " returns 32
+--- echo char2nr("ABC") " returns 65
+--- echo char2nr("Γ‘") " returns 225
+--- echo char2nr("Γ‘"[0]) " returns 195
+--- echo char2nr("\<M-x>") " returns 128
--- <Non-ASCII characters are always treated as UTF-8 characters.
--- {utf8} is ignored, it exists only for backwards-compatibility.
--- A combining character is a separate character.
@@ -901,8 +924,9 @@ function vim.fn.chansend(id, data) end
---
--- Returns 0 if {string} is not a |String|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetChar()->char2nr()
+--- <
---
--- @param string string
--- @param utf8? any
@@ -927,11 +951,11 @@ function vim.fn.charclass(string) end
--- position given with {expr} instead of the byte position.
---
--- Example:
---- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >
---- charcol('.') returns 3
---- col('.') returns 7
+--- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >vim
+--- echo charcol('.') " returns 3
+--- echo col('.') " returns 7
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetPos()->col()
--- <
---
@@ -966,14 +990,15 @@ function vim.fn.charcol(expr, winid) end
--- from the character index and |utf16idx()| for getting the
--- UTF-16 index from the character index.
--- Refer to |string-offset-encoding| for more information.
---- Examples: >
---- echo charidx('áb́ć', 3) returns 1
---- echo charidx('áb́ć', 6, 1) returns 4
---- echo charidx('áb́ć', 16) returns -1
---- echo charidx('a😊😊', 4, 0, 1) returns 2
+--- Examples: >vim
+--- echo charidx('áb́ć', 3) " returns 1
+--- echo charidx('áb́ć', 6, 1) " returns 4
+--- echo charidx('áb́ć', 16) " returns -1
+--- echo charidx('a😊😊', 4, 0, 1) " returns 2
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->charidx(idx)
+--- <
---
--- @param string string
--- @param idx integer
@@ -996,14 +1021,14 @@ function vim.fn.charidx(string, idx, countcc, utf16) end
--- this to another chdir() to restore the directory.
--- On failure, returns an empty string.
---
---- Example: >
+--- Example: >vim
--- let save_dir = chdir(newdir)
--- if save_dir != ""
--- " ... do some work
--- call chdir(save_dir)
--- endif
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetDir()->chdir()
--- <
---
@@ -1018,8 +1043,9 @@ function vim.fn.chdir(dir) end
--- When {lnum} is invalid -1 is returned.
--- See |C-indenting|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->cindent()
+--- <
---
--- @param lnum integer
--- @return integer
@@ -1030,7 +1056,7 @@ function vim.fn.cindent(lnum) end
--- If {win} is specified, use the window with this number or
--- window ID instead of the current window.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWin()->clearmatches()
--- <
---
@@ -1059,11 +1085,11 @@ function vim.fn.clearmatches(win) end
--- For the screen column position use |virtcol()|. For the
--- character position use |charcol()|.
--- Note that only marks in the current file can be used.
---- Examples: >
---- col(".") column of cursor
---- col("$") length of cursor line plus one
---- col("'t") column of mark t
---- col("'" .. markname) column of mark markname
+--- Examples: >vim
+--- echo col(".") " column of cursor
+--- echo col("$") " length of cursor line plus one
+--- echo col("'t") " column of mark t
+--- echo col("'" .. markname) " column of mark markname
--- <The first column is 1. Returns 0 if {expr} is invalid or when
--- the window with ID {winid} is not found.
--- For an uppercase mark the column may actually be in another
@@ -1071,10 +1097,10 @@ function vim.fn.clearmatches(win) end
--- For the cursor position, when 'virtualedit' is active, the
--- column is one higher if the cursor is after the end of the
--- line. Also, when using a <Cmd> mapping the cursor isn't
---- moved, this can be used to obtain the column in Insert mode: >
---- :imap <F2> <Cmd>echo col(".").."\n"<CR>
+--- moved, this can be used to obtain the column in Insert mode: >vim
+--- imap <F2> <Cmd>echo col(".").."\n"<CR>
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetPos()->col()
--- <
---
@@ -1100,7 +1126,7 @@ function vim.fn.col(expr, winid) end
--- The match can be selected with CTRL-N and CTRL-P as usual with
--- Insert mode completion. The popup menu will appear if
--- specified, see |ins-completion-menu|.
---- Example: >
+--- Example: >vim
--- inoremap <F5> <C-R>=ListMonths()<CR>
---
--- func ListMonths()
@@ -1113,8 +1139,9 @@ function vim.fn.col(expr, winid) end
--- an empty string is returned to avoid a zero being inserted.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetMatches()->complete(col('.'))
+--- <
---
--- @param startcol any
--- @param matches any
@@ -1128,8 +1155,9 @@ function vim.fn.complete(startcol, matches) end
--- See |complete-functions| for an explanation of {expr}. It is
--- the same as one item in the list that 'omnifunc' would return.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMoreMatches()->complete_add()
+--- <
---
--- @param expr any
--- @return 0|1|2
@@ -1194,7 +1222,7 @@ function vim.fn.complete_check() end
---
--- Returns an empty |Dictionary| on error.
---
---- Examples: >
+--- Examples: >vim
--- " Get all items
--- call complete_info()
--- " Get only 'mode'
@@ -1202,7 +1230,7 @@ function vim.fn.complete_check() end
--- " Get only 'mode' and 'pum_visible'
--- call complete_info(['mode', 'pum_visible'])
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetItems()->complete_info()
--- <
---
@@ -1221,11 +1249,11 @@ function vim.fn.complete_info(what) end
--- some systems the string is wrapped when it doesn't fit.
---
--- {choices} is a String, with the individual choices separated
---- by '\n', e.g. >
+--- by '\n', e.g. >vim
--- confirm("Save changes?", "&Yes\n&No\n&Cancel")
--- <The letter after the '&' is the shortcut key for that choice.
--- Thus you can type 'c' to select "Cancel". The shortcut does
---- not need to be the first letter: >
+--- not need to be the first letter: >vim
--- confirm("file has been modified", "&Save\nSave &All")
--- <For the console, the first letter of each choice is used as
--- the default shortcut key. Case is ignored.
@@ -1244,7 +1272,7 @@ function vim.fn.complete_info(what) end
--- If the user aborts the dialog by pressing <Esc>, CTRL-C,
--- or another valid interrupt key, confirm() returns 0.
---
---- An example: >
+--- An example: >vim
--- let choice = confirm("What do you want?",
--- \ "&Apples\n&Oranges\n&Bananas", 2)
--- if choice == 0
@@ -1261,7 +1289,7 @@ function vim.fn.complete_info(what) end
--- don't fit, a vertical layout is used anyway. For some systems
--- the horizontal layout is always used.
---
---- Can also be used as a |method|in: >
+--- Can also be used as a |method|in: >vim
--- BuildMessage()->confirm("&Yes\n&No")
--- <
---
@@ -1280,8 +1308,9 @@ function vim.fn.confirm(msg, choices, default, type) end
--- changing an item changes the contents of both |Lists|.
--- A |Dictionary| is copied in a similar way as a |List|.
--- Also see |deepcopy()|.
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->copy()
+--- <
---
--- @param expr any
--- @return any
@@ -1290,14 +1319,15 @@ function vim.fn.copy(expr) end
--- Return the cosine of {expr}, measured in radians, as a |Float|.
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo cos(100)
---- < 0.862319 >
---- :echo cos(-4.01)
+--- Examples: >vim
+--- echo cos(100)
+--- < 0.862319 >vim
+--- echo cos(-4.01)
--- < -0.646043
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->cos()
+--- <
---
--- @param expr any
--- @return number
@@ -1307,14 +1337,15 @@ function vim.fn.cos(expr) end
--- [1, inf].
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo cosh(0.5)
---- < 1.127626 >
---- :echo cosh(-0.5)
+--- Examples: >vim
+--- echo cosh(0.5)
+--- < 1.127626 >vim
+--- echo cosh(-0.5)
--- < -1.127626
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->cosh()
+--- <
---
--- @param expr any
--- @return number
@@ -1332,7 +1363,7 @@ function vim.fn.cosh(expr) end
--- occurrences of {expr} is returned. Zero is returned when
--- {expr} is an empty string.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->count(val)
--- <
---
@@ -1419,8 +1450,9 @@ function vim.fn.cursor(lnum, col, off) end
--- position within a <Tab> or after the last character.
--- Returns 0 when the position could be set, -1 otherwise.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCursorPos()->cursor()
+--- <
---
--- @param list any
--- @return any
@@ -1434,7 +1466,7 @@ function vim.fn.cursor(list) end
--- Returns |TRUE| if successfully interrupted the program.
--- Otherwise returns |FALSE|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPid()->debugbreak()
--- <
---
@@ -1461,8 +1493,9 @@ function vim.fn.debugbreak(pid) end
--- {noref} set to 1 will fail.
--- Also see |copy()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetObject()->deepcopy()
+--- <
---
--- @param expr any
--- @param noref? any
@@ -1487,8 +1520,9 @@ function vim.fn.deepcopy(expr, noref) end
--- operation was successful and -1/true when the deletion failed
--- or partly failed.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->delete()
+--- <
---
--- @param fname integer
--- @param flags? string
@@ -1508,7 +1542,7 @@ function vim.fn.delete(fname, flags) end
--- when using |line()| this refers to the current buffer. Use "$"
--- to refer to the last line in buffer {buf}.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBuffer()->deletebufline(1)
--- <
---
@@ -1528,7 +1562,7 @@ function vim.fn.deletebufline(buf, first, last) end
--- After this is called, every change on {dict} and on keys
--- matching {pattern} will result in {callback} being invoked.
---
---- For example, to watch all global variables: >
+--- For example, to watch all global variables: >vim
--- silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
--- function! OnDictChanged(d,k,z)
--- echomsg string(a:k) string(a:z)
@@ -1595,8 +1629,9 @@ function vim.fn.did_filetype() end
--- line, "'m" mark m, etc.
--- Returns 0 if the current window is not in diff mode.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->diff_filler()
+--- <
---
--- @param lnum integer
--- @return any
@@ -1612,7 +1647,7 @@ function vim.fn.diff_filler(lnum) end
--- The highlight ID can be used with |synIDattr()| to obtain
--- syntax information about the highlighting.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->diff_hlID(col)
--- <
---
@@ -1628,15 +1663,15 @@ function vim.fn.diff_hlID(lnum, col) end
---
--- Also see |digraph_getlist()|.
---
---- Examples: >
+--- Examples: >vim
--- " Get a built-in digraph
---- :echo digraph_get('00') " Returns '∞'
+--- echo digraph_get('00') " Returns '∞'
---
--- " Get a user-defined digraph
---- :call digraph_set('aa', 'あ')
---- :echo digraph_get('aa') " Returns 'あ'
+--- call digraph_set('aa', 'あ')
+--- echo digraph_get('aa') " Returns 'あ'
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetChars()->digraph_get()
--- <
---
@@ -1650,14 +1685,14 @@ function vim.fn.digraph_get(chars) end
---
--- Also see |digraph_get()|.
---
---- Examples: >
+--- Examples: >vim
--- " Get user-defined digraphs
---- :echo digraph_getlist()
+--- echo digraph_getlist()
---
--- " Get all the digraphs, including default digraphs
---- :echo digraph_getlist(1)
+--- echo digraph_getlist(1)
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetNumber()->digraph_getlist()
--- <
---
@@ -1678,10 +1713,10 @@ function vim.fn.digraph_getlist(listall) end
--- If you want to define multiple digraphs at once, you can use
--- |digraph_setlist()|.
---
---- Example: >
+--- Example: >vim
--- call digraph_set(' ', 'あ')
--- <
---- Can be used as a |method|: >
+--- Can be used as a |method|: >vim
--- GetString()->digraph_set('あ')
--- <
---
@@ -1694,17 +1729,17 @@ function vim.fn.digraph_set(chars, digraph) end
--- digraphs at once. {digraphlist} is a list composed of lists,
--- where each list contains two strings with {chars} and
--- {digraph} as in |digraph_set()|. *E1216*
---- Example: >
+--- Example: >vim
--- call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
--- <
---- It is similar to the following: >
+--- It is similar to the following: >vim
--- for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
--- call digraph_set(chars, digraph)
--- endfor
--- <Except that the function returns after the first error,
--- following digraphs will not be added.
---
---- Can be used as a |method|: >
+--- Can be used as a |method|: >vim
--- GetList()->digraph_setlist()
--- <
---
@@ -1720,31 +1755,33 @@ function vim.fn.digraph_setlist(digraphlist) end
--- - |v:false| and |v:null| are empty, |v:true| is not.
--- - A |Blob| is empty when its length is zero.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->empty()
+--- <
---
--- @param expr any
--- @return any
function vim.fn.empty(expr) end
--- Return all of environment variables as dictionary. You can
---- check if an environment variable exists like this: >
---- :echo has_key(environ(), 'HOME')
+--- check if an environment variable exists like this: >vim
+--- echo has_key(environ(), 'HOME')
--- <Note that the variable name may be CamelCase; to ignore case
---- use this: >
---- :echo index(keys(environ()), 'HOME', 0, 1) != -1
+--- use this: >vim
+--- echo index(keys(environ()), 'HOME', 0, 1) != -1
+--- <
---
--- @return any
function vim.fn.environ() end
--- Escape the characters in {chars} that occur in {string} with a
---- backslash. Example: >
---- :echo escape('c:\program files\vim', ' \')
+--- backslash. Example: >vim
+--- echo escape('c:\program files\vim', ' \')
--- <results in: >
--- c:\\program\ files\\vim
--- <Also see |shellescape()| and |fnameescape()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->escape(' \')
--- <
---
@@ -1759,8 +1796,9 @@ function vim.fn.escape(string, chars) end
--- of them. Also works for |Funcref|s that refer to existing
--- functions.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- argv->join()->eval()
+--- <
---
--- @param string string
--- @return any
@@ -1796,8 +1834,9 @@ function vim.fn.eventhandler() end
--- -1 not implemented on this system
--- |exepath()| can be used to get the full path of an executable.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCommand()->executable()
+--- <
---
--- @param expr any
--- @return any
@@ -1807,9 +1846,9 @@ function vim.fn.executable(expr) end
--- If {command} is a |String|, returns {command} output.
--- If {command} is a |List|, returns concatenated outputs.
--- Line continuations in {command} are not recognized.
---- Examples: >
+--- Examples: >vim
--- echo execute('echon "foo"')
---- < foo >
+--- < foo >vim
--- echo execute(['echon "foo"', 'echon "bar"'])
--- < foobar
---
@@ -1820,7 +1859,7 @@ function vim.fn.executable(expr) end
--- The default is "silent". Note that with "silent!", unlike
--- `:redir`, error messages are dropped.
---
---- To get a list of lines use `split()` on the result: >
+--- To get a list of lines use `split()` on the result: >vim
--- execute('args')->split("\n")
---
--- <This function is not available in the |sandbox|.
@@ -1830,8 +1869,9 @@ function vim.fn.executable(expr) end
--- To execute a command in another window than the current one
--- use `win_execute()`.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCommand()->execute()
+--- <
---
--- @param command any
--- @param silent? boolean
@@ -1843,7 +1883,7 @@ function vim.fn.execute(command, silent) end
--- Returns empty string otherwise.
--- If {expr} starts with "./" the |current-directory| is used.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCommand()->exepath()
--- <
---
@@ -1864,11 +1904,11 @@ function vim.fn.exepath(expr) end
--- entries, |List| items, etc.
--- Beware that evaluating an index may
--- cause an error message for an invalid
---- expression. E.g.: >
---- :let l = [1, 2, 3]
---- :echo exists("l[5]")
---- < 0 >
---- :echo exists("l[xx]")
+--- 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,
@@ -1908,38 +1948,39 @@ function vim.fn.exepath(expr) end
--- ##event autocommand for this event is
--- supported.
---
---- Examples: >
---- exists("&mouse")
---- exists("$HOSTNAME")
---- exists("*strftime")
---- exists("*s:MyFunc")
---- exists("*MyFunc")
---- exists("bufcount")
---- exists(":Make")
---- exists("#CursorHold")
---- exists("#BufReadPre#*.gz")
---- exists("#filetypeindent")
---- exists("#filetypeindent#FileType")
---- exists("#filetypeindent#FileType#*")
---- exists("##ColorScheme")
+--- Examples: >vim
+--- echo exists("&mouse")
+--- echo exists("$HOSTNAME")
+--- echo exists("*strftime")
+--- echo exists("*s:MyFunc")
+--- echo exists("*MyFunc")
+--- 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: >
---- exists(":make")
---- <NOT working example: >
---- exists(":make install")
+--- 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: >
---- exists(bufcount)
+--- 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.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Varname()->exists()
+--- <
---
--- @param expr any
--- @return 0|1
@@ -1949,14 +1990,15 @@ function vim.fn.exists(expr) end
--- [0, inf].
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo exp(2)
---- < 7.389056 >
---- :echo exp(-1)
+--- Examples: >vim
+--- echo exp(2)
+--- < 7.389056 >vim
+--- echo exp(-1)
--- < 0.367879
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->exp()
+--- <
---
--- @param expr any
--- @return any
@@ -2006,18 +2048,18 @@ function vim.fn.exp(expr) end
--- :r root (one extension removed)
--- :e extension only
---
---- Example: >
---- :let &tags = expand("%:p:h") .. "/tags"
+--- Example: >vim
+--- let &tags = expand("%:p:h") .. "/tags"
--- <Note that when expanding a string that starts with '%', '#' or
---- '<', any following text is ignored. This does NOT work: >
---- :let doesntwork = expand("%:h.bak")
---- <Use this: >
---- :let doeswork = expand("%:h") .. ".bak"
+--- '<', any following text is ignored. This does NOT work: >vim
+--- let doesntwork = expand("%:h.bak")
+--- <Use this: >vim
+--- let doeswork = expand("%:h") .. ".bak"
--- <Also note that expanding "<cfile>" and others only returns the
--- referenced file name without further expansion. If "<cfile>"
--- is "~/.cshrc", you need to do another expand() to have the
---- "~/" expanded into the path of the home directory: >
---- :echo expand(expand("<cfile>"))
+--- "~/" expanded into the path of the home directory: >vim
+--- echo expand(expand("<cfile>"))
--- <
--- There cannot be white space between the variables and the
--- following modifier. The |fnamemodify()| function can be used
@@ -2037,8 +2079,8 @@ function vim.fn.exp(expr) end
--- {nosuf} argument is given and it is |TRUE|.
--- Names for non-existing files are included. The "**" item can
--- be used to search in a directory tree. For example, to find
---- all "README" files in the current directory and below: >
---- :echo expand("**/README")
+--- all "README" files in the current directory and below: >vim
+--- echo expand("**/README")
--- <
--- expand() can also be used to expand variables and environment
--- variables that are only known in a shell. But this can be
@@ -2052,8 +2094,9 @@ function vim.fn.exp(expr) end
--- See |glob()| for finding existing files. See |system()| for
--- getting the raw output of an external command.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Getpattern()->expand()
+--- <
---
--- @param string string
--- @param nosuf? boolean
@@ -2076,12 +2119,14 @@ function vim.fn.expand(string, nosuf, list) end
--- Returns the expanded string. If an error is encountered
--- during expansion, the unmodified {string} is returned.
---
---- Example: >
---- :echo expandcmd('make %<.o')
+--- Example: >vim
+--- echo expandcmd('make %<.o')
+--- < >
--- make /path/runtime/doc/builtin.o
---- :echo expandcmd('make %<.o', {'errmsg': v:true})
+--- < >vim
+--- echo expandcmd('make %<.o', {'errmsg': v:true})
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCommand()->expandcmd()
--- <
---
@@ -2098,16 +2143,16 @@ function vim.fn.expandcmd(string, options) end
--- item with index {expr3} in {expr1}. When {expr3} is zero
--- insert before the first item. When {expr3} is equal to
--- len({expr1}) then {expr2} is appended.
---- Examples: >
---- :echo sort(extend(mylist, [7, 5]))
---- :call extend(mylist, [2, 3], 1)
+--- Examples: >vim
+--- echo sort(extend(mylist, [7, 5]))
+--- call extend(mylist, [2, 3], 1)
--- <When {expr1} is the same List as {expr2} then the number of
--- items copied is equal to the original length of the List.
--- E.g., when {expr3} is 1 you get N new copies of the first item
--- (where N is the original length of the List).
--- Use |add()| to concatenate one item to a list. To concatenate
---- two lists into a new list use the + operator: >
---- :let newlist = [1, 2, 3] + [4, 5]
+--- two lists into a new list use the + operator: >vim
+--- let newlist = [1, 2, 3] + [4, 5]
--- <
--- If they are |Dictionaries|:
--- Add all entries from {expr2} to {expr1}.
@@ -2125,7 +2170,7 @@ function vim.fn.expandcmd(string, options) end
--- fails.
--- Returns {expr1}. Returns 0 on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->extend(otherlist)
--- <
---
@@ -2189,8 +2234,9 @@ function vim.fn.extendnew(expr1, expr2, expr3) end
---
--- Return value is always 0.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetInput()->feedkeys()
+--- <
---
--- @param string string
--- @param mode? string
@@ -2210,14 +2256,19 @@ function vim.fn.file_readable(file) end
--- expression, which is used as a String.
--- If you don't care about the file being readable you can use
--- |glob()|.
---- {file} is used as-is, you may want to expand wildcards first: >
+--- {file} is used as-is, you may want to expand wildcards first: >vim
--- echo filereadable('~/.vimrc')
+--- < >
--- 0
+--- < >vim
--- echo filereadable(expand('~/.vimrc'))
+--- < >
--- 1
+--- <
---
---- <Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->filereadable()
+--- <
---
--- @param file string
--- @return 0|1
@@ -2228,8 +2279,9 @@ function vim.fn.filereadable(file) end
--- exist, or is not writable, the result is 0. If {file} is a
--- directory, and we can write to it, the result is 2.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->filewritable()
+--- <
---
--- @param file string
--- @return 0|1
@@ -2248,11 +2300,11 @@ function vim.fn.filewritable(file) end
--- the current item. For a |Blob| |v:key| has the index of the
--- current byte.
---
---- Examples: >
+--- Examples: >vim
--- call filter(mylist, 'v:val !~ "OLD"')
---- <Removes the items where "OLD" appears. >
+--- <Removes the items where "OLD" appears. >vim
--- call filter(mydict, 'v:key >= 8')
---- <Removes the items with a key below 8. >
+--- <Removes the items with a key below 8. >vim
--- call filter(var, 0)
--- <Removes all the items, thus clears the |List| or |Dictionary|.
---
@@ -2264,19 +2316,19 @@ function vim.fn.filewritable(file) end
--- 1. the key or the index of the current item.
--- 2. the value of the current item.
--- The function must return |TRUE| if the item should be kept.
---- Example that keeps the odd items of a list: >
+--- Example that keeps the odd items of a list: >vim
--- func Odd(idx, val)
--- return a:idx % 2 == 1
--- endfunc
--- call filter(mylist, function('Odd'))
---- <It is shorter when using a |lambda|: >
+--- <It is shorter when using a |lambda|: >vim
--- call filter(myList, {idx, val -> idx * val <= 42})
---- <If you do not use "val" you can leave it out: >
+--- <If you do not use "val" you can leave it out: >vim
--- call filter(myList, {idx -> idx % 2 == 1})
--- <
--- The operation is done in-place. If you want a |List| or
---- |Dictionary| to remain unmodified make a copy first: >
---- :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
+--- |Dictionary| to remain unmodified make a copy first: >vim
+--- let l = filter(copy(mylist), 'v:val =~ "KEEP"')
---
--- <Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
--- filtered. When an error is encountered while evaluating
@@ -2284,8 +2336,9 @@ function vim.fn.filewritable(file) end
--- {expr2} is a Funcref errors inside a function are ignored,
--- unless it was defined with the "abort" flag.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->filter(expr2)
+--- <
---
--- @param expr1 any
--- @param expr2 any
@@ -2309,8 +2362,9 @@ function vim.fn.filter(expr1, expr2) end
---
--- This is quite similar to the ex-command `:find`.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->finddir()
+--- <
---
--- @param name string
--- @param path? string
@@ -2320,13 +2374,14 @@ function vim.fn.finddir(name, path, count) end
--- Just like |finddir()|, but find a file instead of a directory.
--- Uses 'suffixesadd'.
---- Example: >
---- :echo findfile("tags.vim", ".;")
+--- Example: >vim
+--- echo findfile("tags.vim", ".;")
--- <Searches from the directory of the current file upwards until
--- it finds the file "tags.vim".
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->findfile()
+--- <
---
--- @param name string
--- @param path? string
@@ -2346,13 +2401,13 @@ function vim.fn.findfile(name, path, count) end
---
--- If there is an error the number zero is returned.
---
---- Example: >
---- :echo flatten([1, [2, [3, 4]], 5])
---- < [1, 2, 3, 4, 5] >
---- :echo flatten([1, [2, [3, 4]], 5], 1)
+--- Example: >vim
+--- echo flatten([1, [2, [3, 4]], 5])
+--- < [1, 2, 3, 4, 5] >vim
+--- echo flatten([1, [2, [3, 4]], 5], 1)
--- < [1, 2, [3, 4], 5]
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->flatten()
--- <
---
@@ -2377,20 +2432,21 @@ function vim.fn.flattennew(list, maxdepth) end
--- 64-bit Number support is enabled, 0x7fffffffffffffff or
--- -0x7fffffffffffffff). NaN results in -0x80000000 (or when
--- 64-bit Number support is enabled, -0x8000000000000000).
---- Examples: >
+--- Examples: >vim
--- echo float2nr(3.95)
---- < 3 >
+--- < 3 >vim
--- echo float2nr(-23.45)
---- < -23 >
+--- < -23 >vim
--- echo float2nr(1.0e100)
---- < 2147483647 (or 9223372036854775807) >
+--- < 2147483647 (or 9223372036854775807) >vim
--- echo float2nr(-1.0e150)
---- < -2147483647 (or -9223372036854775807) >
+--- < -2147483647 (or -9223372036854775807) >vim
--- echo float2nr(1.0e-100)
--- < 0
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->float2nr()
+--- <
---
--- @param expr any
--- @return any
@@ -2400,16 +2456,17 @@ function vim.fn.float2nr(expr) end
--- {expr} as a |Float| (round down).
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
+--- Examples: >vim
--- echo floor(1.856)
---- < 1.0 >
+--- < 1.0 >vim
--- echo floor(-5.456)
---- < -6.0 >
+--- < -6.0 >vim
--- echo floor(4.0)
--- < 4.0
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->floor()
+--- <
---
--- @param expr any
--- @return any
@@ -2424,14 +2481,15 @@ function vim.fn.floor(expr) end
--- {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
--- |Number|.
---- Examples: >
---- :echo fmod(12.33, 1.22)
---- < 0.13 >
---- :echo fmod(-12.33, 1.22)
+--- Examples: >vim
+--- echo fmod(12.33, 1.22)
+--- < 0.13 >vim
+--- echo fmod(-12.33, 1.22)
--- < -0.13
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->fmod(1.22)
+--- <
---
--- @param expr1 any
--- @param expr2 any
@@ -2439,7 +2497,7 @@ function vim.fn.floor(expr) end
function vim.fn.fmod(expr1, expr2) end
--- Escape {string} for use as file name command argument. All
---- characters that have a special meaning, such as '%' and '|'
+--- characters that have a special meaning, such as `'%'` and `'|'`
--- are escaped with a backslash.
--- For most systems the characters escaped are
--- " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
@@ -2447,14 +2505,15 @@ function vim.fn.fmod(expr1, expr2) end
--- A leading '+' and '>' is also escaped (special after |:edit|
--- and |:write|). And a "-" by itself (special after |:cd|).
--- Returns an empty string on error.
---- Example: >
---- :let fname = '+some str%nge|name'
---- :exe "edit " .. fnameescape(fname)
---- <results in executing: >
+--- Example: >vim
+--- let fname = '+some str%nge|name'
+--- exe "edit " .. fnameescape(fname)
+--- <results in executing: >vim
--- edit \+some\ str\%nge\|name
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->fnameescape()
+--- <
---
--- @param string string
--- @return string
@@ -2463,8 +2522,8 @@ function vim.fn.fnameescape(string) end
--- Modify file name {fname} according to {mods}. {mods} is a
--- string of characters like it is used for file names on the
--- command line. See |filename-modifiers|.
---- Example: >
---- :echo fnamemodify("main.c", ":p:h")
+--- Example: >vim
+--- echo fnamemodify("main.c", ":p:h")
--- <results in: >
--- /home/user/vim/vim/src
--- <If {mods} is empty or an unsupported modifier is used then
@@ -2476,8 +2535,9 @@ function vim.fn.fnameescape(string) end
--- Note: Environment variables don't work in {fname}, use
--- |expand()| first then.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->fnamemodify(':p:h')
+--- <
---
--- @param fname integer
--- @param mods string
@@ -2490,8 +2550,9 @@ function vim.fn.fnamemodify(fname, mods) end
--- {lnum} is used like with |getline()|. Thus "." is the current
--- line, "'m" mark m, etc.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->foldclosed()
+--- <
---
--- @param lnum integer
--- @return integer
@@ -2503,8 +2564,9 @@ function vim.fn.foldclosed(lnum) end
--- {lnum} is used like with |getline()|. Thus "." is the current
--- line, "'m" mark m, etc.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->foldclosedend()
+--- <
---
--- @param lnum integer
--- @return integer
@@ -2521,7 +2583,7 @@ function vim.fn.foldclosedend(lnum) end
--- {lnum} is used like with |getline()|. Thus "." is the current
--- line, "'m" mark m, etc.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->foldlevel()
--- <
---
@@ -2556,7 +2618,7 @@ function vim.fn.foldtext() end
--- line, "'m" mark m, etc.
--- Useful when exporting folded text, e.g., to HTML.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->foldtextresult()
--- <
---
@@ -2575,7 +2637,7 @@ function vim.fn.foldtextresult(lnum) end
--- For example `fullcommand('s')`, `fullcommand('sub')`,
--- `fullcommand(':%substitute')` all return "substitute".
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->fullcommand()
--- <
---
@@ -2594,7 +2656,7 @@ function vim.fn.fullcommand(name) end
--- instead). {name} cannot be a builtin function.
--- Returns 0 on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFuncname()->funcref([arg])
--- <
---
@@ -2610,7 +2672,7 @@ function vim.fn.funcref(name, arglist, dict) end
---
--- {name} can also be a Funcref or a partial. When it is a
--- partial the dict stored in it will be used and the {dict}
---- argument is not allowed. E.g.: >
+--- argument is not allowed. E.g.: >vim
--- let FuncWithArg = function(dict.Func, [arg])
--- let Broken = function(dict.Func, [arg], dict)
--- <
@@ -2623,38 +2685,41 @@ function vim.fn.funcref(name, arglist, dict) end
--- the Funcref and will be used when the Funcref is called.
---
--- The arguments are passed to the function in front of other
---- arguments, but after any argument from |method|. Example: >
+--- arguments, but after any argument from |method|. Example: >vim
--- func Callback(arg1, arg2, name)
--- "...
+--- endfunc
--- let Partial = function('Callback', ['one', 'two'])
--- "...
--- call Partial('name')
---- <Invokes the function as with: >
+--- <Invokes the function as with: >vim
--- call Callback('one', 'two', 'name')
---
---- <With a |method|: >
+--- <With a |method|: >vim
--- func Callback(one, two, three)
--- "...
+--- endfunc
--- let Partial = function('Callback', ['two'])
--- "...
--- eval 'one'->Partial('three')
---- <Invokes the function as with: >
+--- <Invokes the function as with: >vim
--- call Callback('one', 'two', 'three')
---
--- <The function() call can be nested to add more arguments to the
--- Funcref. The extra arguments are appended to the list of
---- arguments. Example: >
+--- arguments. Example: >vim
--- func Callback(arg1, arg2, name)
--- "...
+--- endfunc
--- let Func = function('Callback', ['one'])
--- let Func2 = function(Func, ['two'])
--- "...
--- call Func2('name')
---- <Invokes the function as with: >
+--- <Invokes the function as with: >vim
--- call Callback('one', 'two', 'name')
---
--- <The Dictionary is only useful when calling a "dict" function.
---- In that case the {dict} is passed in as "self". Example: >
+--- In that case the {dict} is passed in as "self". Example: >vim
--- function Callback() dict
--- echo "called for " .. self.name
--- endfunction
@@ -2665,24 +2730,26 @@ function vim.fn.funcref(name, arglist, dict) end
--- call Func() " will echo: called for example
--- <The use of function() is not needed when there are no extra
--- arguments, these two are equivalent, if Callback() is defined
---- as context.Callback(): >
+--- as context.Callback(): >vim
--- let Func = function('Callback', context)
--- let Func = context.Callback
---
---- <The argument list and the Dictionary can be combined: >
+--- <The argument list and the Dictionary can be combined: >vim
--- function Callback(arg1, count) dict
--- "...
+--- endfunction
--- let context = {"name": "example"}
--- let Func = function('Callback', ['one'], context)
--- "...
--- call Func(500)
---- <Invokes the function as with: >
+--- <Invokes the function as with: >vim
--- call context.Callback('one', 500)
--- <
--- Returns 0 on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFuncname()->function([arg])
+--- <
---
--- @param name string
--- @param arglist? any
@@ -2716,8 +2783,9 @@ function vim.fn.garbagecollect(atexit) end
--- Get item {idx} from |List| {list}. When this item is not
--- available return {default}. Return zero when {default} is
--- omitted.
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->get(idx)
+--- <
---
--- @param list any[]
--- @param idx integer
@@ -2737,7 +2805,7 @@ function vim.fn.get(blob, idx, default) end
--- Get item with key {key} from |Dictionary| {dict}. When this
--- item is not available return {default}. Return zero when
---- {default} is omitted. Useful example: >
+--- {default} is omitted. Useful example: >vim
--- let val = get(g:, 'var_name', 'default')
--- <This gets the value of g:var_name if it exists, and uses
--- "default" when it does not exist.
@@ -2798,8 +2866,8 @@ function vim.fn.getbufinfo(buf) end
--- displayed in the window in the past.
--- If you want the line number of the
--- last known cursor position in a given
---- window, use |line()|: >
---- :echo line('.', {winid})
+--- window, use |line()|: >vim
+--- echo line('.', {winid})
--- <
--- linecount Number of lines in the buffer (only
--- valid when loaded)
@@ -2816,20 +2884,20 @@ function vim.fn.getbufinfo(buf) end
--- windows List of |window-ID|s that display this
--- buffer
---
---- Examples: >
+--- Examples: >vim
--- for buf in getbufinfo()
--- echo buf.name
--- endfor
--- for buf in getbufinfo({'buflisted':1})
--- if buf.changed
---- ....
+--- " ....
--- endif
--- endfor
--- <
---- To get buffer-local options use: >
+--- To get buffer-local options use: >vim
--- getbufvar({bufnr}, '&option_name')
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBufnr()->getbufinfo()
--- <
---
@@ -2858,10 +2926,10 @@ function vim.fn.getbufinfo(dict) end
--- This function works only for loaded buffers. For unloaded and
--- non-existing buffers, an empty |List| is returned.
---
---- Example: >
---- :let lines = getbufline(bufnr("myfile"), 1, "$")
+--- Example: >vim
+--- let lines = getbufline(bufnr("myfile"), 1, "$")
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetBufnr()->getbufline(lnum)
--- <
---
@@ -2895,11 +2963,11 @@ function vim.fn.getbufoneline(buf, lnum) end
--- For the use of {buf}, see |bufname()| above.
--- When the buffer or variable doesn't exist {def} or an empty
--- string is returned, there is no error message.
---- Examples: >
---- :let bufmodified = getbufvar(1, "&mod")
---- :echo "todo myvar = " .. getbufvar("todo", "myvar")
+--- Examples: >vim
+--- let bufmodified = getbufvar(1, "&mod")
+--- echo "todo myvar = " .. getbufvar("todo", "myvar")
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetBufnr()->getbufvar(varname)
--- <
---
@@ -2932,8 +3000,9 @@ function vim.fn.getcellwidths() end
--- position refers to the position in the list. For other
--- buffers, it is set to the length of the list.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBufnr()->getchangelist()
+--- <
---
--- @param buf? integer|string
--- @return table[]
@@ -2972,7 +3041,7 @@ function vim.fn.getchangelist(buf) end
--- |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
--- |getmousepos()| can also be used. Mouse move events will be
--- ignored.
---- This example positions the mouse as it would normally happen: >
+--- This example positions the mouse as it would normally happen: >vim
--- let c = getchar()
--- if c == "\<LeftMouse>" && v:mouse_win > 0
--- exe v:mouse_win .. "wincmd w"
@@ -2987,20 +3056,20 @@ function vim.fn.getchangelist(buf) end
--- There is no mapping for the character.
--- Key codes are replaced, thus when the user presses the <Del>
--- key you get the code for the <Del> key, not the raw character
---- sequence. Examples: >
+--- sequence. Examples: >vim
--- getchar() == "\<Del>"
--- getchar() == "\<S-Left>"
---- <This example redefines "f" to ignore case: >
---- :nmap f :call FindChar()<CR>
---- :function FindChar()
---- : let c = nr2char(getchar())
---- : while col('.') < col('$') - 1
---- : normal l
---- : if getline('.')[col('.') - 1] ==? c
---- : break
---- : endif
---- : endwhile
---- :endfunction
+--- <This example redefines "f" to ignore case: >vim
+--- nmap f :call FindChar()<CR>
+--- function FindChar()
+--- let c = nr2char(getchar())
+--- while col('.') < col('$') - 1
+--- normal l
+--- if getline('.')[col('.') - 1] ==? c
+--- break
+--- endif
+--- endwhile
+--- endfunction
--- <
---
--- @return integer
@@ -3032,12 +3101,13 @@ function vim.fn.getcharmod() end
--- of the last character.
---
--- Example:
---- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >
+--- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >vim
--- getcharpos('.') returns [0, 5, 3, 0]
--- getpos('.') returns [0, 5, 7, 0]
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMark()->getcharpos()
+--- <
---
--- @param expr any
--- @return integer[]
@@ -3057,9 +3127,9 @@ function vim.fn.getcharpos(expr) end
---
--- This can be useful to always have |;| and |,| search
--- forward/backward regardless of the direction of the previous
---- character search: >
---- :nnoremap <expr> ; getcharsearch().forward ? ';' : ','
---- :nnoremap <expr> , getcharsearch().forward ? ',' : ';'
+--- character search: >vim
+--- nnoremap <expr> ; getcharsearch().forward ? ';' : ','
+--- nnoremap <expr> , getcharsearch().forward ? ',' : ';'
--- <Also see |setcharsearch()|.
---
--- @return table[]
@@ -3093,8 +3163,8 @@ function vim.fn.getcmdcompltype() end
--- Return the current command-line. Only works when the command
--- line is being edited, thus requires use of |c_CTRL-\_e| or
--- |c_CTRL-R_=|.
---- Example: >
---- :cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
+--- Example: >vim
+--- cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
--- <Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and
--- |setcmdline()|.
--- Returns an empty string when entering a password or using
@@ -3209,13 +3279,13 @@ function vim.fn.getcmdwintype() end
---
--- If {type} is "cmdline", then the |cmdline-completion| result is
--- returned. For example, to complete the possible values after
---- a ":call" command: >
+--- a ":call" command: >vim
--- echo getcompletion('call ', 'cmdline')
--- <
--- If there are no matches, an empty list is returned. An
--- invalid value for {type} produces an error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPattern()->getcompletion('color')
--- <
---
@@ -3242,14 +3312,14 @@ function vim.fn.getcompletion(pat, type, filtered) end
--- current value of the buffer if it is not the current window.
--- If {winid} is invalid a list with zeroes is returned.
---
---- This can be used to save and restore the cursor position: >
+--- This can be used to save and restore the cursor position: >vim
--- let save_cursor = getcurpos()
--- MoveTheCursorAround
--- call setpos('.', save_cursor)
--- <Note that this only works within the window. See
--- |winrestview()| for restoring more state.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->getcurpos()
--- <
---
@@ -3261,12 +3331,13 @@ function vim.fn.getcurpos(winid) end
--- List is a character index instead of a byte index.
---
--- Example:
---- With the cursor on '보' in line 3 with text "μ—¬λ³΄μ„Έμš”": >
---- getcursorcharpos() returns [0, 3, 2, 0, 3]
---- getcurpos() returns [0, 3, 4, 0, 3]
+--- With the cursor on '보' in line 3 with text "μ—¬λ³΄μ„Έμš”": >vim
+--- getcursorcharpos() " returns [0, 3, 2, 0, 3]
+--- getcurpos() " returns [0, 3, 4, 0, 3]
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->getcursorcharpos()
+--- <
---
--- @param winid? integer
--- @return any
@@ -3278,7 +3349,7 @@ function vim.fn.getcursorcharpos(winid) end
--- ignored.
--- Tabs and windows are identified by their respective numbers,
--- 0 means current tab or window. Missing tab number implies 0.
---- Thus the following are equivalent: >
+--- Thus the following are equivalent: >vim
--- getcwd(0)
--- getcwd(0, 0)
--- <If {winnr} is -1 it is ignored, only the tab is resolved.
@@ -3287,8 +3358,9 @@ function vim.fn.getcursorcharpos(winid) end
--- directory is returned.
--- Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->getcwd()
+--- <
---
--- @param winnr? integer
--- @param tabnr? integer
@@ -3296,15 +3368,16 @@ function vim.fn.getcursorcharpos(winid) end
function vim.fn.getcwd(winnr, tabnr) end
--- Return the value of environment variable {name}. The {name}
---- argument is a string, without a leading '$'. Example: >
+--- argument is a string, without a leading '$'. Example: >vim
--- myHome = getenv('HOME')
---
--- <When the variable does not exist |v:null| is returned. That
--- is different from a variable set to an empty string.
--- See also |expr-env|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetVarname()->getenv()
+--- <
---
--- @param name string
--- @return string
@@ -3333,13 +3406,13 @@ function vim.fn.getfontname(name) end
--- "rwx" flags represent, in turn, the permissions of the owner
--- of the file, the group the file belongs to, and other users.
--- If a user does not have a given permission the flag for this
---- is replaced with the string "-". Examples: >
---- :echo getfperm("/etc/passwd")
---- :echo getfperm(expand("~/.config/nvim/init.vim"))
+--- is replaced with the string "-". Examples: >vim
+--- echo getfperm("/etc/passwd")
+--- echo getfperm(expand("~/.config/nvim/init.vim"))
--- <This will hopefully (from a security point of view) display
--- the string "rw-r--r--" or even "rw-------".
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFilename()->getfperm()
--- <
--- For setting permissions use |setfperm()|.
@@ -3355,8 +3428,9 @@ function vim.fn.getfperm(fname) end
--- If the size of {fname} is too big to fit in a Number then -2
--- is returned.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFilename()->getfsize()
+--- <
---
--- @param fname integer
--- @return integer
@@ -3368,8 +3442,9 @@ function vim.fn.getfsize(fname) end
--- |localtime()| and |strftime()|.
--- If the file {fname} can't be found -1 is returned.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFilename()->getftime()
+--- <
---
--- @param fname integer
--- @return integer
@@ -3388,14 +3463,15 @@ function vim.fn.getftime(fname) end
--- Socket "socket"
--- FIFO "fifo"
--- All other "other"
---- Example: >
+--- Example: >vim
--- getftype("/home")
--- <Note that a type such as "link" will only be returned on
--- systems that support it. On some systems only "dir" and
--- "file" are returned.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFilename()->getftype()
+--- <
---
--- @param fname integer
--- @return 'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'
@@ -3420,7 +3496,7 @@ function vim.fn.getftype(fname) end
--- filename filename if available
--- lnum line number
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->getjumplist()
--- <
---
@@ -3430,11 +3506,11 @@ function vim.fn.getftype(fname) end
function vim.fn.getjumplist(winnr, tabnr) end
--- Without {end} the result is a String, which is line {lnum}
---- from the current buffer. Example: >
+--- from the current buffer. Example: >vim
--- getline(1)
--- <When {lnum} is a String that doesn't start with a
--- digit, |line()| is called to translate the String into a Number.
---- To get the line under the cursor: >
+--- To get the line under the cursor: >vim
--- getline(".")
--- <When {lnum} is a number smaller than 1 or bigger than the
--- number of lines in the buffer, an empty string is returned.
@@ -3445,12 +3521,12 @@ function vim.fn.getjumplist(winnr, tabnr) end
--- {end} is used in the same way as {lnum}.
--- Non-existing lines are silently omitted.
--- When {end} is before {lnum} an empty |List| is returned.
---- Example: >
---- :let start = line('.')
---- :let end = search("^$") - 1
---- :let lines = getline(start, end)
+--- Example: >vim
+--- let start = line('.')
+--- let end = search("^$") - 1
+--- let lines = getline(start, end)
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- ComputeLnum()->getline()
---
--- <To get lines from another buffer see |getbufline()| and
@@ -3487,9 +3563,9 @@ function vim.fn.getline(lnum, end_) end
--- location list for the window {nr}.
--- Returns an empty Dictionary if window {nr} does not exist.
---
---- Examples (See also |getqflist-examples|): >
---- :echo getloclist(3, {'all': 0})
---- :echo getloclist(5, {'filewinid': 0})
+--- Examples (See also |getqflist-examples|): >vim
+--- echo getloclist(3, {'all': 0})
+--- echo getloclist(5, {'filewinid': 0})
--- <
---
--- @param nr integer
@@ -3515,8 +3591,9 @@ function vim.fn.getloclist(nr, what) end
--- Refer to |getpos()| for getting information about a specific
--- mark.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBufnr()->getmarklist()
+--- <
---
--- @param buf? any
--- @return any
@@ -3531,26 +3608,26 @@ function vim.fn.getmarklist(buf) end
--- window ID instead of the current window. If {win} is invalid,
--- an empty list is returned.
--- Example: >vim
---- :echo getmatches()
+--- echo getmatches()
--- < >
--- [{"group": "MyGroup1", "pattern": "TODO",
--- "priority": 10, "id": 1}, {"group": "MyGroup2",
--- "pattern": "FIXME", "priority": 10, "id": 2}]
--- < >vim
---- :let m = getmatches()
---- :call clearmatches()
---- :echo getmatches()
+--- let m = getmatches()
+--- call clearmatches()
+--- echo getmatches()
--- < >
--- []
--- < >vim
---- :call setmatches(m)
---- :echo getmatches()
+--- call setmatches(m)
+--- echo getmatches()
--- < >
--- [{"group": "MyGroup1", "pattern": "TODO",
--- "priority": 10, "id": 1}, {"group": "MyGroup2",
--- "pattern": "FIXME", "priority": 10, "id": 2}]
--- < >vim
---- :unlet m
+--- unlet m
--- <
---
--- @param win? any
@@ -3616,14 +3693,15 @@ function vim.fn.getpid() end
--- A very large column number equal to |v:maxcol| can be returned,
--- in which case it means "after the end of the line".
--- If {expr} is invalid, returns a list with all zeros.
---- This can be used to save and restore the position of a mark: >
+--- This can be used to save and restore the position of a mark: >vim
--- let save_a_mark = getpos("'a")
---- ...
+--- " ...
--- call setpos("'a", save_a_mark)
--- <Also see |getcharpos()|, |getcurpos()| and |setpos()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMark()->getpos()
+--- <
---
--- @param expr any
--- @return any
@@ -3654,11 +3732,11 @@ function vim.fn.getpos(expr) end
--- you may need to explicitly check for zero).
---
--- Useful application: Find pattern matches in multiple files and
---- do something with them: >
---- :vimgrep /theword/jg *.c
---- :for d in getqflist()
---- : echo bufname(d.bufnr) ':' d.lnum '=' d.text
---- :endfor
+--- do something with them: >vim
+--- vimgrep /theword/jg *.c
+--- for d in getqflist()
+--- echo bufname(d.bufnr) ':' d.lnum '=' d.text
+--- endfor
--- <
--- If the optional {what} dictionary argument is supplied, then
--- returns only the items listed in {what} as a dictionary. The
@@ -3723,10 +3801,10 @@ function vim.fn.getpos(expr) end
--- to "".
--- winid quickfix |window-ID|. If not present, set to 0
---
---- Examples (See also |getqflist-examples|): >
---- :echo getqflist({'all': 1})
---- :echo getqflist({'nr': 2, 'title': 1})
---- :echo getqflist({'lines' : ["F1:10:L10"]})
+--- Examples (See also |getqflist-examples|): >vim
+--- echo getqflist({'all': 1})
+--- echo getqflist({'nr': 2, 'title': 1})
+--- echo getqflist({'lines' : ["F1:10:L10"]})
--- <
---
--- @param what? any
@@ -3734,8 +3812,8 @@ function vim.fn.getpos(expr) end
function vim.fn.getqflist(what) end
--- The result is a String, which is the contents of register
---- {regname}. Example: >
---- :let cliptext = getreg('*')
+--- {regname}. Example: >vim
+--- let cliptext = getreg('*')
--- <When register {regname} was not set the result is an empty
--- string.
--- The {regname} argument must be a string.
@@ -3755,8 +3833,9 @@ function vim.fn.getqflist(what) end
---
--- If {regname} is not specified, |v:register| is used.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRegname()->getreg()
+--- <
---
--- @param regname? string
--- @param list? any
@@ -3786,8 +3865,9 @@ function vim.fn.getreg(regname, list) end
--- If {regname} is not specified, |v:register| is used.
--- The returned Dictionary can be passed to |setreg()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRegname()->getreginfo()
+--- <
---
--- @param regname? string
--- @return table
@@ -3803,8 +3883,9 @@ function vim.fn.getreginfo(regname) end
--- The {regname} argument is a string. If {regname} is not
--- specified, |v:register| is used.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRegname()->getregtype()
+--- <
---
--- @param regname? string
--- @return string
@@ -3841,9 +3922,9 @@ function vim.fn.getregtype(regname) end
--- this dictionary.
--- version Vimscript version, always 1
---
---- Examples: >
---- :echo getscriptinfo({'name': 'myscript'})
---- :echo getscriptinfo({'sid': 15}).variables
+--- Examples: >vim
+--- echo getscriptinfo({'name': 'myscript'})
+--- echo getscriptinfo({'sid': 15}).variables
--- <
---
--- @param opts? table
@@ -3862,8 +3943,9 @@ function vim.fn.getscriptinfo(opts) end
--- tabpage-local variables
--- windows List of |window-ID|s in the tab page.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTabnr()->gettabinfo()
+--- <
---
--- @param tabnr? integer
--- @return any
@@ -3878,8 +3960,9 @@ function vim.fn.gettabinfo(tabnr) end
--- When the tab or variable doesn't exist {def} or an empty
--- string is returned, there is no error message.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTabnr()->gettabvar(varname)
+--- <
---
--- @param tabnr integer
--- @param varname string
@@ -3905,15 +3988,16 @@ function vim.fn.gettabvar(tabnr, varname, def) end
--- or buffer-local variable.
--- When the tab, window or variable doesn't exist {def} or an
--- empty string is returned, there is no error message.
---- Examples: >
---- :let list_is_on = gettabwinvar(1, 2, '&list')
---- :echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
+--- Examples: >vim
+--- let list_is_on = gettabwinvar(1, 2, '&list')
+--- echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
--- <
---- To obtain all window-local variables use: >
+--- To obtain all window-local variables use: >vim
--- gettabwinvar({tabnr}, {winnr}, '&')
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTabnr()->gettabwinvar(winnr, varname)
+--- <
---
--- @param tabnr integer
--- @param winnr integer
@@ -3949,7 +4033,7 @@ function vim.fn.gettabwinvar(tabnr, winnr, varname, def) end
---
--- See |tagstack| for more information about the tag stack.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->gettagstack()
--- <
---
@@ -4004,8 +4088,9 @@ function vim.fn.gettext(text) end
--- winrow topmost screen line of the window;
--- "row" from |win_screenpos()|
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->getwininfo()
+--- <
---
--- @param winid? integer
--- @return any
@@ -4021,7 +4106,7 @@ function vim.fn.getwininfo(winid) end
--- When using a value less than 10 and no response is received
--- within that time, a previously reported position is returned,
--- if available. This can be used to poll for the position and
---- do some work in the meantime: >
+--- do some work in the meantime: >vim
--- while 1
--- let res = getwinpos(1)
--- if res[0] >= 0
@@ -4030,7 +4115,7 @@ function vim.fn.getwininfo(winid) end
--- " Do some work here
--- endwhile
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTimeout()->getwinpos()
--- <
---
@@ -4055,11 +4140,11 @@ function vim.fn.getwinposx() end
function vim.fn.getwinposy() end
--- Like |gettabwinvar()| for the current tabpage.
---- Examples: >
---- :let list_is_on = getwinvar(2, '&list')
---- :echo "myvar = " .. getwinvar(1, 'myvar')
+--- Examples: >vim
+--- let list_is_on = getwinvar(2, '&list')
+--- echo "myvar = " .. getwinvar(1, 'myvar')
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetWinnr()->getwinvar(varname)
--- <
---
@@ -4095,17 +4180,18 @@ function vim.fn.getwinvar(winnr, varname, def) end
--- |TRUE| then all symbolic links are included.
---
--- For most systems backticks can be used to get files names from
---- any external command. Example: >
---- :let tagfiles = glob("`find . -name tags -print`")
---- :let &tags = substitute(tagfiles, "\n", ",", "g")
+--- any external command. Example: >vim
+--- let tagfiles = glob("`find . -name tags -print`")
+--- let &tags = substitute(tagfiles, "\n", ",", "g")
--- <The result of the program inside the backticks should be one
--- item per line. Spaces inside an item are allowed.
---
--- See |expand()| for expanding special Vim variables. See
--- |system()| for getting the raw output of an external command.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetExpr()->glob()
+--- <
---
--- @param expr any
--- @param nosuf? boolean
@@ -4116,16 +4202,20 @@ function vim.fn.glob(expr, nosuf, list, alllinks) end
--- Convert a file pattern, as used by glob(), into a search
--- pattern. The result can be used to match with a string that
---- is a file name. E.g. >
+--- is a file name. E.g. >vim
--- if filename =~ glob2regpat('Make*.mak')
---- <This is equivalent to: >
+--- " ...
+--- endif
+--- <This is equivalent to: >vim
--- if filename =~ '^Make.*\.mak$'
+--- " ...
+--- endif
--- <When {string} is an empty string the result is "^$", match an
--- empty string.
--- Note that the result depends on the system. On MS-Windows
--- a backslash usually means a path separator.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetExpr()->glob2regpat()
--- <
---
@@ -4134,8 +4224,8 @@ function vim.fn.glob(expr, nosuf, list, alllinks) end
function vim.fn.glob2regpat(string) end
--- Perform glob() for String {expr} on all directories in {path}
---- and concatenate the results. Example: >
---- :echo globpath(&rtp, "syntax/c.vim")
+--- and concatenate the results. Example: >vim
+--- echo globpath(&rtp, "syntax/c.vim")
--- <
--- {path} is a comma-separated list of directory names. Each
--- directory name is prepended to {expr} and expanded like with
@@ -4155,20 +4245,20 @@ function vim.fn.glob2regpat(string) end
--- with all matching files. The advantage of using a List is, you
--- also get filenames containing newlines correctly. Otherwise
--- the result is a String and when there are several matches,
---- they are separated by <NL> characters. Example: >
---- :echo globpath(&rtp, "syntax/c.vim", 0, 1)
+--- they are separated by <NL> characters. Example: >vim
+--- echo globpath(&rtp, "syntax/c.vim", 0, 1)
--- <
--- {allinks} is used as with |glob()|.
---
--- The "**" item can be used to search in a directory tree.
--- For example, to find all "README.txt" files in the directories
---- in 'runtimepath' and below: >
---- :echo globpath(&rtp, "**/README.txt")
+--- in 'runtimepath' and below: >vim
+--- echo globpath(&rtp, "**/README.txt")
--- <Upwards search and limiting the depth of "**" is not
--- supported, thus using 'path' will not always work properly.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetExpr()->globpath(&rtp)
--- <
---
@@ -4189,9 +4279,9 @@ function vim.fn.globpath(path, expr, nosuf, list, allinks) end
---
--- <If the code has a syntax error then Vimscript may skip the
--- rest of the line. Put |:if| and |:endif| on separate lines to
---- avoid the syntax error: >
+--- avoid the syntax error: >vim
--- if has('feature')
---- let x = this->breaks->without->the->feature
+--- let x = this_breaks_without_the_feature()
--- endif
--- <
--- Vim's compile-time feature-names (prefixed with "+") are not
@@ -4200,12 +4290,16 @@ function vim.fn.globpath(path, expr, nosuf, list, allinks) end
---
--- Feature names can be:
--- 1. Nvim version. For example the "nvim-0.2.1" feature means
---- that Nvim is version 0.2.1 or later: >
---- :if has("nvim-0.2.1")
+--- that Nvim is version 0.2.1 or later: >vim
+--- if has("nvim-0.2.1")
+--- " ...
+--- endif
---
--- <2. Runtime condition or other pseudo-feature. For example the
---- "win32" feature checks if the current system is Windows: >
---- :if has("win32")
+--- "win32" feature checks if the current system is Windows: >vim
+--- if has("win32")
+--- " ...
+--- endif
--- < *feature-list*
--- List of supported pseudo-feature names:
--- acl |ACL| support.
@@ -4231,12 +4325,16 @@ function vim.fn.globpath(path, expr, nosuf, list, allinks) end
---
--- *has-patch*
--- 3. Vim patch. For example the "patch123" feature means that
---- Vim patch 123 at the current |v:version| was included: >
---- :if v:version > 602 || v:version == 602 && has("patch148")
+--- Vim patch 123 at the current |v:version| was included: >vim
+--- if v:version > 602 || v:version == 602 && has("patch148")
+--- " ...
+--- endif
---
--- <4. Vim version. For example the "patch-7.4.237" feature means
---- that Nvim is Vim-compatible to version 7.4.237 or later. >
---- :if has("patch-7.4.237")
+--- that Nvim is Vim-compatible to version 7.4.237 or later. >vim
+--- if has("patch-7.4.237")
+--- " ...
+--- endif
--- <
---
--- @param feature any
@@ -4247,8 +4345,9 @@ function vim.fn.has(feature) end
--- has an entry with key {key}. FALSE otherwise. The {key}
--- argument is a string.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mydict->has_key(key)
+--- <
---
--- @param dict any
--- @param key any
@@ -4261,18 +4360,19 @@ function vim.fn.has_key(dict, key) end
---
--- Tabs and windows are identified by their respective numbers,
--- 0 means current tab or window. Missing argument implies 0.
---- Thus the following are equivalent: >
---- haslocaldir()
---- haslocaldir(0)
---- haslocaldir(0, 0)
+--- Thus the following are equivalent: >vim
+--- echo haslocaldir()
+--- echo haslocaldir(0)
+--- echo haslocaldir(0, 0)
--- <With {winnr} use that window in the current tabpage.
--- With {winnr} and {tabnr} use the window in that tabpage.
--- {winnr} can be the window number or the |window-ID|.
--- If {winnr} is -1 it is ignored, only the tab is resolved.
--- Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->haslocaldir()
+--- <
---
--- @param winnr? integer
--- @param tabnr? integer
@@ -4302,15 +4402,16 @@ function vim.fn.haslocaldir(winnr, tabnr) end
--- When {mode} is omitted, "nvo" is used.
---
--- This function is useful to check if a mapping already exists
---- to a function in a Vim script. Example: >
---- :if !hasmapto('\ABCdoit')
---- : map <Leader>d \ABCdoit
---- :endif
+--- to a function in a Vim script. Example: >vim
+--- if !hasmapto('\ABCdoit')
+--- map <Leader>d \ABCdoit
+--- endif
--- <This installs the mapping to "\ABCdoit" only if there isn't
--- already a mapping to "\ABCdoit".
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRHS()->hasmapto()
+--- <
---
--- @param what any
--- @param mode? string
@@ -4347,14 +4448,15 @@ function vim.fn.highlight_exists(name) end
--- The result is a Number: TRUE if the operation was successful,
--- otherwise FALSE is returned.
---
---- Example: >
---- :call histadd("input", strftime("%Y %b %d"))
---- :let date=input("Enter date: ")
+--- Example: >vim
+--- call histadd("input", strftime("%Y %b %d"))
+--- let date=input("Enter date: ")
--- <This function is not available in the |sandbox|.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetHistory()->histadd('search')
+--- <
---
--- @param history any
--- @param item any
@@ -4376,24 +4478,25 @@ function vim.fn.histadd(history, item) end
--- is returned.
---
--- Examples:
---- Clear expression register history: >
---- :call histdel("expr")
+--- Clear expression register history: >vim
+--- call histdel("expr")
--- <
---- Remove all entries starting with "*" from the search history: >
---- :call histdel("/", '^\*')
+--- Remove all entries starting with "*" from the search history: >vim
+--- call histdel("/", '^\*')
--- <
---- The following three are equivalent: >
---- :call histdel("search", histnr("search"))
---- :call histdel("search", -1)
---- :call histdel("search", '^' .. histget("search", -1) .. '$')
+--- The following three are equivalent: >vim
+--- call histdel("search", histnr("search"))
+--- call histdel("search", -1)
+--- call histdel("search", '^' .. histget("search", -1) .. '$')
--- <
--- To delete the last search pattern and use the last-but-one for
---- the "n" command and 'hlsearch': >
---- :call histdel("search", -1)
---- :let \@/ = histget("search", -1)
+--- the "n" command and 'hlsearch': >vim
+--- call histdel("search", -1)
+--- let \@/ = histget("search", -1)
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetHistory()->histdel()
+--- <
---
--- @param history any
--- @param item? any
@@ -4407,15 +4510,16 @@ function vim.fn.histdel(history, item) end
--- omitted, the most recent item from the history is used.
---
--- Examples:
---- Redo the second last search from history. >
---- :execute '/' .. histget("search", -2)
+--- Redo the second last search from history. >vim
+--- execute '/' .. histget("search", -2)
---
--- <Define an Ex command ":H {num}" that supports re-execution of
---- the {num}th entry from the output of |:history|. >
---- :command -nargs=1 H execute histget("cmd", 0+<args>)
+--- the {num}th entry from the output of |:history|. >vim
+--- command -nargs=1 H execute histget("cmd", 0+<args>)
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetHistory()->histget()
+--- <
---
--- @param history any
--- @param index? any
@@ -4426,10 +4530,10 @@ function vim.fn.histget(history, index) end
--- See |hist-names| for the possible values of {history}.
--- If an error occurred, -1 is returned.
---
---- Example: >
---- :let inp_index = histnr("expr")
+--- Example: >vim
+--- let inp_index = histnr("expr")
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetHistory()->histnr()
--- <
---
@@ -4442,11 +4546,12 @@ function vim.fn.histnr(history) end
--- zero is returned.
--- This can be used to retrieve information about the highlight
--- group. For example, to get the background color of the
---- "Comment" group: >
---- :echo synIDattr(synIDtrans(hlID("Comment")), "bg")
+--- "Comment" group: >vim
+--- echo synIDattr(synIDtrans(hlID("Comment")), "bg")
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->hlID()
+--- <
---
--- @param name string
--- @return integer
@@ -4458,7 +4563,7 @@ function vim.fn.hlID(name) end
--- been defined for it, it may also have been used for a syntax
--- item.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->hlexists()
--- <
---
@@ -4484,7 +4589,7 @@ function vim.fn.hostname() end
--- from/to UCS-2 is automatically changed to use UTF-8. You
--- cannot use UCS-2 in a string anyway, because of the NUL bytes.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->iconv('latin1', 'utf-8')
--- <
---
@@ -4498,8 +4603,8 @@ function vim.fn.iconv(string, from, to) end
--- container type (|List|, |Dict|, |Blob| and |Partial|). It is
--- guaranteed that for the mentioned types `id(v1) ==# id(v2)`
--- returns true iff `type(v1) == type(v2) && v1 is v2`.
---- Note that |v:_null_string|, |v:_null_list|, |v:_null_dict| and
---- |v:_null_blob| have the same `id()` with different types
+--- Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
+--- `v:_null_blob` have the same `id()` with different types
--- because they are internally represented as NULL pointers.
--- `id()` returns a hexadecimal representanion of the pointers to
--- the containers (i.e. like `0x994a40`), same as `printf("%p",
@@ -4519,8 +4624,9 @@ function vim.fn.id(expr) end
--- |getline()|.
--- When {lnum} is invalid -1 is returned.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->indent()
+--- <
---
--- @param lnum integer
--- @return integer
@@ -4546,12 +4652,15 @@ function vim.fn.indent(lnum) end
--- case must match.
---
--- -1 is returned when {expr} is not found in {object}.
---- Example: >
---- :let idx = index(words, "the")
---- :if index(numbers, 123) >= 0
+--- Example: >vim
+--- let idx = index(words, "the")
+--- if index(numbers, 123) >= 0
+--- " ...
+--- endif
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetObject()->index(what)
+--- <
---
--- @param object any
--- @param expr any
@@ -4591,14 +4700,15 @@ function vim.fn.index(object, expr, start, ic) end
--- index; may be negative for an item relative to
--- the end
--- Returns -1 when {expr} evaluates to v:false for all the items.
---- Example: >
---- :let l = [#{n: 10}, #{n: 20}, #{n: 30}]
---- :echo indexof(l, "v:val.n == 20")
---- :echo indexof(l, {i, v -> v.n == 30})
---- :echo indexof(l, "v:val.n == 20", #{startidx: 1})
+--- Example: >vim
+--- let l = [#{n: 10}, #{n: 20}, #{n: 30}]
+--- echo indexof(l, "v:val.n == 20")
+--- echo indexof(l, {i, v -> v.n == 30})
+--- echo indexof(l, "v:val.n == 20", #{startidx: 1})
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- mylist->indexof(expr)
+--- <
---
--- @param object any
--- @param expr any
@@ -4633,22 +4743,22 @@ function vim.fn.input(prompt, text, completion) end
--- The input is entered just like a command-line, with the same
--- editing commands and mappings. There is a separate history
--- for lines typed for input().
---- Example: >
---- :if input("Coffee or beer? ") == "beer"
---- : echo "Cheers!"
---- :endif
+--- Example: >vim
+--- if input("Coffee or beer? ") == "beer"
+--- echo "Cheers!"
+--- endif
--- <
--- If the optional {text} argument is present and not empty, this
--- is used for the default reply, as if the user typed this.
---- Example: >
---- :let color = input("Color? ", "white")
+--- Example: >vim
+--- let color = input("Color? ", "white")
---
--- <The optional {completion} argument specifies the type of
--- completion supported for the input. Without it completion is
--- not performed. The supported completion types are the same as
--- that can be supplied to a user-defined command using the
--- "-complete=" argument. Refer to |:command-completion| for
---- more information. Example: >
+--- more information. Example: >vim
--- let fname = input("File: ", "", "file")
---
--- < *input()-highlight* *E5400* *E5402*
@@ -4669,7 +4779,7 @@ function vim.fn.input(prompt, text, completion) end
--- sections must be ordered so that next hl_start_col is greater
--- then or equal to previous hl_end_col.
---
---- Example (try some input with parentheses): >
+--- Example (try some input with parentheses): >vim
--- highlight RBP1 guibg=Red ctermbg=red
--- highlight RBP2 guibg=Yellow ctermbg=yellow
--- highlight RBP3 guibg=Green ctermbg=green
@@ -4714,16 +4824,17 @@ function vim.fn.input(prompt, text, completion) end
--- that further characters follow in the mapping, e.g., by using
--- |:execute| or |:normal|.
---
---- Example with a mapping: >
---- :nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
---- :function GetFoo()
---- : call inputsave()
---- : let g:Foo = input("enter search pattern: ")
---- : call inputrestore()
---- :endfunction
+--- Example with a mapping: >vim
+--- nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
+--- function GetFoo()
+--- call inputsave()
+--- let g:Foo = input("enter search pattern: ")
+--- call inputrestore()
+--- endfunction
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetPrompt()->input()
+--- <
---
--- @param opts table
--- @return any
@@ -4748,12 +4859,13 @@ function vim.fn.inputdialog(...) end
--- Make sure {textlist} has less than 'lines' entries, otherwise
--- it won't work. It's a good idea to put the entry number at
--- the start of the string. And put a prompt in the first item.
---- Example: >
+--- Example: >vim
--- let color = inputlist(['Select color:', '1. red',
--- \ '2. green', '3. blue'])
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetChoices()->inputlist()
+--- <
---
--- @param textlist any
--- @return any
@@ -4787,8 +4899,9 @@ function vim.fn.inputsave() end
--- typed on the command-line in response to the issued prompt.
--- NOTE: Command-line completion is not supported.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPrompt()->inputsecret()
+--- <
---
--- @param prompt any
--- @param text? any
@@ -4803,16 +4916,17 @@ function vim.fn.inputsecret(prompt, text) end
--- like omitting {idx}. A negative {idx} is also possible, see
--- |list-index|. -1 inserts just before the last item.
---
---- Returns the resulting |List| or |Blob|. Examples: >
---- :let mylist = insert([2, 3, 5], 1)
---- :call insert(mylist, 4, -1)
---- :call insert(mylist, 6, len(mylist))
+--- Returns the resulting |List| or |Blob|. Examples: >vim
+--- let mylist = insert([2, 3, 5], 1)
+--- call insert(mylist, 4, -1)
+--- call insert(mylist, 6, len(mylist))
--- <The last example can be done simpler with |add()|.
--- Note that when {item} is a |List| it is inserted as a single
--- item. Use |extend()| to concatenate |Lists|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->insert(item)
+--- <
---
--- @param object any
--- @param item any
@@ -4823,23 +4937,25 @@ function vim.fn.insert(object, item, idx) end
--- Interrupt script execution. It works more or less like the
--- user typing CTRL-C, most commands won't execute and control
--- returns to the user. This is useful to abort execution
---- from lower down, e.g. in an autocommand. Example: >
---- :function s:check_typoname(file)
---- : if fnamemodify(a:file, ':t') == '['
---- : echomsg 'Maybe typo'
---- : call interrupt()
---- : endif
---- :endfunction
---- :au BufWritePre * call s:check_typoname(expand('<amatch>'))
+--- from lower down, e.g. in an autocommand. Example: >vim
+--- function s:check_typoname(file)
+--- if fnamemodify(a:file, ':t') == '['
+--- echomsg 'Maybe typo'
+--- call interrupt()
+--- endif
+--- endfunction
+--- au BufWritePre * call s:check_typoname(expand('<amatch>'))
+--- <
---
--- @return any
function vim.fn.interrupt() end
--- Bitwise invert. The argument is converted to a number. A
---- List, Dict or Float argument causes an error. Example: >
---- :let bits = invert(bits)
---- <Can also be used as a |method|: >
---- :let bits = bits->invert()
+--- List, Dict or Float argument causes an error. Example: >vim
+--- let bits = invert(bits)
+--- <Can also be used as a |method|: >vim
+--- let bits = bits->invert()
+--- <
---
--- @param expr any
--- @return any
@@ -4850,22 +4966,24 @@ function vim.fn.invert(expr) end
--- exist, or isn't a directory, the result is |FALSE|. {directory}
--- is any expression, which is used as a String.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->isdirectory()
+--- <
---
--- @param directory any
--- @return 0|1
function vim.fn.isdirectory(directory) end
--- Return 1 if {expr} is a positive infinity, or -1 a negative
---- infinity, otherwise 0. >
---- :echo isinf(1.0 / 0.0)
---- < 1 >
---- :echo isinf(-1.0 / 0.0)
+--- infinity, otherwise 0. >vim
+--- echo isinf(1.0 / 0.0)
+--- < 1 >vim
+--- echo isinf(-1.0 / 0.0)
--- < -1
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->isinf()
+--- <
---
--- @param expr any
--- @return 1|0|-1
@@ -4875,28 +4993,30 @@ function vim.fn.isinf(expr) end
--- name of a locked variable.
--- The string argument {expr} must be the name of a variable,
--- |List| item or |Dictionary| entry, not the variable itself!
---- Example: >
---- :let alist = [0, ['a', 'b'], 2, 3]
---- :lockvar 1 alist
---- :echo islocked('alist') " 1
---- :echo islocked('alist[1]') " 0
+--- Example: >vim
+--- let alist = [0, ['a', 'b'], 2, 3]
+--- lockvar 1 alist
+--- echo islocked('alist') " 1
+--- echo islocked('alist[1]') " 0
---
--- <When {expr} is a variable that does not exist you get an error
--- message. Use |exists()| to check for existence.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->islocked()
+--- <
---
--- @param expr any
--- @return 0|1
function vim.fn.islocked(expr) end
---- Return |TRUE| if {expr} is a float with value NaN. >
+--- Return |TRUE| if {expr} is a float with value NaN. >vim
--- echo isnan(0.0 / 0.0)
--- < 1
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->isnan()
+--- <
---
--- @param expr any
--- @return 0|1
@@ -4906,13 +5026,14 @@ function vim.fn.isnan(expr) end
--- |List| item is a list with two items: the key of a {dict}
--- entry and the value of this entry. The |List| is in arbitrary
--- order. Also see |keys()| and |values()|.
---- Example: >
+--- Example: >vim
--- for [key, value] in items(mydict)
--- echo key .. ': ' .. value
--- endfor
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- mydict->items()
+--- <
---
--- @param dict any
--- @return any
@@ -4952,12 +5073,12 @@ function vim.fn.jobsend(...) end
---
--- Spawns {cmd} as a job.
--- If {cmd} is a List it runs directly (no 'shell').
---- If {cmd} is a String it runs in the 'shell', like this: >
---- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+--- If {cmd} is a String it runs in the 'shell', like this: >vim
+--- call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
--- <(See |shell-unquoting| for details.)
---
---- Example: >
---- :call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
+--- Example: >vim
+--- call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
--- <
--- Returns |job-id| on success, 0 on invalid arguments (or job
--- table is full), -1 if {cmd}[0] or 'shell' is not executable.
@@ -4970,10 +5091,10 @@ function vim.fn.jobsend(...) end
---
--- NOTE: on Windows if {cmd} is a List:
--- - cmd[0] must be an executable (not a "built-in"). If it is
---- in $PATH it can be called by name, without an extension: >
---- :call jobstart(['ping', 'neovim.io'])
---- < If it is a full or partial path, extension is required: >
---- :call jobstart(['System32\ping.exe', 'neovim.io'])
+--- in $PATH it can be called by name, without an extension: >vim
+--- call jobstart(['ping', 'neovim.io'])
+--- < If it is a full or partial path, extension is required: >vim
+--- call jobstart(['System32\ping.exe', 'neovim.io'])
--- < - {cmd} is collapsed to a string of quoted args as expected
--- by CommandLineToArgvW https://msdn.microsoft.com/bb776391
--- unless cmd[0] is some form of "cmd.exe".
@@ -5057,7 +5178,7 @@ function vim.fn.jobstop(id) end
--- {timeout} is the maximum waiting time in milliseconds. If
--- omitted or -1, wait forever.
---
---- Timeout of 0 can be used to check the status of a job: >
+--- Timeout of 0 can be used to check the status of a job: >vim
--- let running = jobwait([{job-id}], 0)[0] == -1
--- <
--- During jobwait() callbacks for jobs not in the {jobs} list may
@@ -5080,14 +5201,15 @@ function vim.fn.jobwait(jobs, timeout) end
--- When {sep} is specified it is put in between the items. If
--- {sep} is omitted a single space is used.
--- Note that {sep} is not added at the end. You might want to
---- add it there too: >
+--- add it there too: >vim
--- let lines = join(mylist, "\n") .. "\n"
--- <String items are used as-is. |Lists| and |Dictionaries| are
--- converted into a string like with |string()|.
--- The opposite function is |split()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->join()
+--- <
---
--- @param list any
--- @param sep? any
@@ -5109,8 +5231,9 @@ function vim.fn.join(list, sep) end
--- recommended and the only one required to be supported.
--- Non-UTF-8 characters are an error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- ReadObject()->json_decode()
+--- <
---
--- @param expr any
--- @return any
@@ -5127,8 +5250,9 @@ function vim.fn.json_decode(expr) end
--- or special escapes like "\t", other are dumped as-is.
--- |Blob|s are converted to arrays of the individual bytes.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetObject()->json_encode()
+--- <
---
--- @param expr any
--- @return any
@@ -5137,20 +5261,21 @@ function vim.fn.json_encode(expr) end
--- Return a |List| with all the keys of {dict}. The |List| is in
--- arbitrary order. Also see |items()| and |values()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mydict->keys()
+--- <
---
--- @param dict any
--- @return any
function vim.fn.keys(dict) end
--- Turn the internal byte representation of keys into a form that
---- can be used for |:map|. E.g. >
---- :let xx = "\<C-Home>"
---- :echo keytrans(xx)
+--- can be used for |:map|. E.g. >vim
+--- let xx = "\<C-Home>"
+--- echo keytrans(xx)
--- < <C-Home>
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- "\<C-Home>"->keytrans()
--- <
---
@@ -5173,7 +5298,7 @@ function vim.fn.last_buffer_nr() end
--- |Dictionary| is returned.
--- Otherwise an error is given and returns zero.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->len()
--- <
---
@@ -5219,11 +5344,11 @@ function vim.fn.len(expr) end
--- the DLL is not in the usual places.
--- For Unix: When compiling your own plugins, remember that the
--- object code must be compiled as position-independent ('PIC').
---- Examples: >
---- :echo libcall("libc.so", "getenv", "HOME")
+--- Examples: >vim
+--- echo libcall("libc.so", "getenv", "HOME")
---
--- <Can also be used as a |method|, the base is passed as the
---- third argument: >
+--- third argument: >vim
--- GetValue()->libcall("libc.so", "getenv")
--- <
---
@@ -5235,13 +5360,13 @@ function vim.fn.libcall(libname, funcname, argument) end
--- Just like |libcall()|, but used for a function that returns an
--- int instead of a string.
---- Examples: >
---- :echo libcallnr("/usr/lib/libc.so", "getpid", "")
---- :call libcallnr("libc.so", "printf", "Hello World!\n")
---- :call libcallnr("libc.so", "sleep", 10)
+--- Examples: >vim
+--- echo libcallnr("/usr/lib/libc.so", "getpid", "")
+--- call libcallnr("libc.so", "printf", "Hello World!\n")
+--- call libcallnr("libc.so", "sleep", 10)
--- <
--- Can also be used as a |method|, the base is passed as the
---- third argument: >
+--- third argument: >vim
--- GetValue()->libcallnr("libc.so", "printf")
--- <
---
@@ -5273,17 +5398,18 @@ function vim.fn.libcallnr(libname, funcname, argument) end
--- With the optional {winid} argument the values are obtained for
--- that window instead of the current window.
--- Returns 0 for invalid values of {expr} and {winid}.
---- Examples: >
---- line(".") line number of the cursor
---- line(".", winid) idem, in window "winid"
---- line("'t") line number of mark t
---- line("'" .. marker) line number of mark marker
+--- Examples: >vim
+--- echo line(".") " line number of the cursor
+--- echo line(".", winid) " idem, in window "winid"
+--- echo line("'t") " line number of mark t
+--- echo line("'" .. marker) " line number of mark marker
--- <
--- To jump to the last known position when opening a file see
--- |last-position-jump|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetValue()->line()
+--- <
---
--- @param expr any
--- @param winid? integer
@@ -5295,15 +5421,16 @@ function vim.fn.line(expr, winid) end
--- the 'fileformat' option for the current buffer. The first
--- line returns 1. UTF-8 encoding is used, 'fileencoding' is
--- ignored. This can also be used to get the byte count for the
---- line just below the last line: >
---- line2byte(line("$") + 1)
+--- line just below the last line: >vim
+--- echo line2byte(line("$") + 1)
--- <This is the buffer size plus one. If 'fileencoding' is empty
--- it is the file size plus one. {lnum} is used like with
--- |getline()|. When {lnum} is invalid -1 is returned.
--- Also see |byte2line()|, |go| and |:goto|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->line2byte()
+--- <
---
--- @param lnum integer
--- @return integer
@@ -5315,46 +5442,49 @@ function vim.fn.line2byte(lnum) end
--- relevant. {lnum} is used just like in |getline()|.
--- When {lnum} is invalid, -1 is returned.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->lispindent()
+--- <
---
--- @param lnum integer
--- @return any
function vim.fn.lispindent(lnum) end
--- Return a Blob concatenating all the number values in {list}.
---- Examples: >
---- list2blob([1, 2, 3, 4]) returns 0z01020304
---- list2blob([]) returns 0z
+--- Examples: >vim
+--- echo list2blob([1, 2, 3, 4]) " returns 0z01020304
+--- echo list2blob([]) " returns 0z
--- <Returns an empty Blob on error. If one of the numbers is
--- negative or more than 255 error *E1239* is given.
---
--- |blob2list()| does the opposite.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetList()->list2blob()
+--- <
---
--- @param list any
--- @return any
function vim.fn.list2blob(list) end
--- Convert each number in {list} to a character string can
---- concatenate them all. Examples: >
---- list2str([32]) returns " "
---- list2str([65, 66, 67]) returns "ABC"
---- <The same can be done (slowly) with: >
---- join(map(list, {nr, val -> nr2char(val)}), '')
+--- concatenate them all. Examples: >vim
+--- echo list2str([32]) " returns " "
+--- echo list2str([65, 66, 67]) " returns "ABC"
+--- <The same can be done (slowly) with: >vim
+--- echo join(map(list, {nr, val -> nr2char(val)}), '')
--- <|str2list()| does the opposite.
---
--- UTF-8 encoding is always used, {utf8} option has no effect,
--- and exists only for backwards-compatibility.
---- With UTF-8 composing characters work as expected: >
---- list2str([97, 769]) returns "á"
+--- With UTF-8 composing characters work as expected: >vim
+--- echo list2str([97, 769]) " returns "á"
--- <
--- Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetList()->list2str()
+--- <
---
--- @param list any
--- @param utf8? any
@@ -5371,14 +5501,15 @@ function vim.fn.localtime() end
--- {expr} must evaluate to a |Float| or a |Number| in the range
--- (0, inf].
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo log(10)
---- < 2.302585 >
---- :echo log(exp(5))
+--- Examples: >vim
+--- echo log(10)
+--- < 2.302585 >vim
+--- echo log(exp(5))
--- < 5.0
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->log()
+--- <
---
--- @param expr any
--- @return any
@@ -5387,14 +5518,15 @@ function vim.fn.log(expr) end
--- Return the logarithm of Float {expr} to base 10 as a |Float|.
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo log10(1000)
---- < 3.0 >
---- :echo log10(0.01)
+--- Examples: >vim
+--- echo log10(1000)
+--- < 3.0 >vim
+--- echo log10(0.01)
--- < -2.0
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->log10()
+--- <
---
--- @param expr any
--- @return any
@@ -5411,8 +5543,8 @@ function vim.fn.log10(expr) end
--- of the current item and for a |List| |v:key| has the index of
--- the current item. For a |Blob| |v:key| has the index of the
--- current byte.
---- Example: >
---- :call map(mylist, '"> " .. v:val .. " <"')
+--- Example: >vim
+--- call map(mylist, '"> " .. v:val .. " <"')
--- <This puts "> " before and " <" after each item in "mylist".
---
--- Note that {expr2} is the result of an expression and is then
@@ -5424,21 +5556,21 @@ function vim.fn.log10(expr) end
--- 1. The key or the index of the current item.
--- 2. the value of the current item.
--- The function must return the new value of the item. Example
---- that changes each value by "key-value": >
+--- that changes each value by "key-value": >vim
--- func KeyValue(key, val)
--- return a:key .. '-' .. a:val
--- endfunc
--- call map(myDict, function('KeyValue'))
---- <It is shorter when using a |lambda|: >
+--- <It is shorter when using a |lambda|: >vim
--- call map(myDict, {key, val -> key .. '-' .. val})
---- <If you do not use "val" you can leave it out: >
+--- <If you do not use "val" you can leave it out: >vim
--- call map(myDict, {key -> 'item: ' .. key})
---- <If you do not use "key" you can use a short name: >
+--- <If you do not use "key" you can use a short name: >vim
--- call map(myDict, {_, val -> 'item: ' .. val})
--- <
--- The operation is done in-place. If you want a |List| or
---- |Dictionary| to remain unmodified make a copy first: >
---- :let tlist = map(copy(mylist), ' v:val .. "\t"')
+--- |Dictionary| to remain unmodified make a copy first: >vim
+--- let tlist = map(copy(mylist), ' v:val .. "\t"')
---
--- <Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
--- filtered. When an error is encountered while evaluating
@@ -5446,7 +5578,7 @@ function vim.fn.log10(expr) end
--- {expr2} is a Funcref errors inside a function are ignored,
--- unless it was defined with the "abort" flag.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->map(expr2)
--- <
---
@@ -5515,11 +5647,12 @@ function vim.fn.map(expr1, expr2) end
--- The mappings local to the current buffer are checked first,
--- then the global mappings.
--- This function can be used to map a key even when it's already
---- mapped, and have it do the original mapping too. Sketch: >
+--- mapped, and have it do the original mapping too. Sketch: >vim
--- exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetKey()->maparg('n')
+--- <
---
--- @param name string
--- @param mode? string
@@ -5553,15 +5686,16 @@ function vim.fn.maparg(name, mode, abbr, dict) end
--- The mappings local to the current buffer are checked first,
--- then the global mappings.
--- This function can be used to check if a mapping can be added
---- without being ambiguous. Example: >
---- :if mapcheck("_vv") == ""
---- : map _vv :set guifont=7x13<CR>
---- :endif
+--- without being ambiguous. Example: >vim
+--- if mapcheck("_vv") == ""
+--- map _vv :set guifont=7x13<CR>
+--- endif
--- <This avoids adding the "_vv" mapping when there already is a
--- mapping for "_v" or for "_vvv".
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetKey()->mapcheck('n')
+--- <
---
--- @param name string
--- @param mode? string
@@ -5574,10 +5708,10 @@ function vim.fn.mapcheck(name, mode, abbr) end
--- |maparg()|. *E460*
--- {mode} is used to define the mode in which the mapping is set,
--- not the "mode" entry in {dict}.
---- Example for saving and restoring a mapping: >
+--- Example for saving and restoring a mapping: >vim
--- let save_map = maparg('K', 'n', 0, 1)
--- nnoremap K somethingelse
---- ...
+--- " ...
--- call mapset('n', 0, save_map)
--- <Note that if you are going to replace a map in several modes,
--- e.g. with `:map!`, you need to save the mapping for all of
@@ -5601,27 +5735,27 @@ function vim.fn.mapset(mode, abbr, dict) end
--- If there is no match -1 is returned.
---
--- For getting submatches see |matchlist()|.
---- Example: >
---- :echo match("testing", "ing") " results in 4
---- :echo match([1, 'x'], '\a') " results in 1
+--- Example: >vim
+--- echo match("testing", "ing") " results in 4
+--- echo match([1, 'x'], '\a') " results in 1
--- <See |string-match| for how {pat} is used.
--- *strpbrk()*
---- Vim doesn't have a strpbrk() function. But you can do: >
---- :let sepidx = match(line, '[.,;: \t]')
+--- Vim doesn't have a strpbrk() function. But you can do: >vim
+--- let sepidx = match(line, '[.,;: \t]')
--- < *strcasestr()*
--- Vim doesn't have a strcasestr() function. But you can add
---- "\c" to the pattern to ignore case: >
---- :let idx = match(haystack, '\cneedle')
+--- "\c" to the pattern to ignore case: >vim
+--- let idx = match(haystack, '\cneedle')
--- <
--- If {start} is given, the search starts from byte index
--- {start} in a String or item {start} in a |List|.
--- The result, however, is still the index counted from the
---- first character/item. Example: >
---- :echo match("testing", "ing", 2)
---- <result is again "4". >
---- :echo match("testing", "ing", 4)
---- <result is again "4". >
---- :echo match("testing", "t", 2)
+--- first character/item. Example: >vim
+--- echo match("testing", "ing", 2)
+--- <result is again "4". >vim
+--- echo match("testing", "ing", 4)
+--- <result is again "4". >vim
+--- echo match("testing", "t", 2)
--- <result is "3".
--- For a String, if {start} > 0 then it is like the string starts
--- {start} bytes later, thus "^" will match at {start}. Except
@@ -5635,7 +5769,7 @@ function vim.fn.mapset(mode, abbr, dict) end
---
--- When {count} is given use the {count}th match. When a match
--- is found in a String the search for the next one starts one
---- character further. Thus this example results in 1: >
+--- character further. Thus this example results in 1: >vim
--- echo match("testing", "..", 0, 2)
--- <In a |List| the search continues in the next item.
--- Note that when {count} is added the way {start} works changes,
@@ -5650,7 +5784,7 @@ function vim.fn.mapset(mode, abbr, dict) end
--- zero matches at the start instead of a number of matches
--- further down in the text.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->match('word')
--- GetList()->match('word')
--- <
@@ -5709,17 +5843,17 @@ function vim.fn.match(expr, pat, start, count) end
---
--- Returns -1 on error.
---
---- Example: >
---- :highlight MyGroup ctermbg=green guibg=green
---- :let m = matchadd("MyGroup", "TODO")
---- <Deletion of the pattern: >
---- :call matchdelete(m)
+--- Example: >vim
+--- highlight MyGroup ctermbg=green guibg=green
+--- let m = matchadd("MyGroup", "TODO")
+--- <Deletion of the pattern: >vim
+--- call matchdelete(m)
---
--- <A list of matches defined by |matchadd()| and |:match| are
--- available from |getmatches()|. All matches can be deleted in
--- one operation by |clearmatches()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetGroup()->matchadd('TODO')
--- <
---
@@ -5758,17 +5892,18 @@ function vim.fn.matchadd(group, pattern, priority, id, dict) end
---
--- Returns -1 on error.
---
---- Example: >
---- :highlight MyGroup ctermbg=green guibg=green
---- :let m = matchaddpos("MyGroup", [[23, 24], 34])
---- <Deletion of the pattern: >
---- :call matchdelete(m)
+--- Example: >vim
+--- highlight MyGroup ctermbg=green guibg=green
+--- let m = matchaddpos("MyGroup", [[23, 24], 34])
+--- <Deletion of the pattern: >vim
+--- call matchdelete(m)
---
--- <Matches added by |matchaddpos()| are returned by
--- |getmatches()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetGroup()->matchaddpos([23, 11])
+--- <
---
--- @param group any
--- @param pos any
@@ -5789,8 +5924,9 @@ function vim.fn.matchaddpos(group, pos, priority, id, dict) end
--- Highlighting matches using the |:match| commands are limited
--- to three matches. |matchadd()| does not have this limitation.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMatch()->matcharg()
+--- <
---
--- @param nr integer
--- @return any
@@ -5803,8 +5939,9 @@ function vim.fn.matcharg(nr) end
--- If {win} is specified, use the window with this number or
--- window ID instead of the current window.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMatch()->matchdelete()
+--- <
---
--- @param id any
--- @param win? any
@@ -5812,25 +5949,26 @@ function vim.fn.matcharg(nr) end
function vim.fn.matchdelete(id, win) end
--- Same as |match()|, but return the index of first character
---- after the match. Example: >
---- :echo matchend("testing", "ing")
+--- after the match. Example: >vim
+--- echo matchend("testing", "ing")
--- <results in "7".
--- *strspn()* *strcspn()*
--- Vim doesn't have a strspn() or strcspn() function, but you can
---- do it with matchend(): >
---- :let span = matchend(line, '[a-zA-Z]')
---- :let span = matchend(line, '[^a-zA-Z]')
+--- do it with matchend(): >vim
+--- let span = matchend(line, '[a-zA-Z]')
+--- let span = matchend(line, '[^a-zA-Z]')
--- <Except that -1 is returned when there are no matches.
---
---- The {start}, if given, has the same meaning as for |match()|. >
---- :echo matchend("testing", "ing", 2)
---- <results in "7". >
---- :echo matchend("testing", "ing", 5)
+--- The {start}, if given, has the same meaning as for |match()|. >vim
+--- echo matchend("testing", "ing", 2)
+--- <results in "7". >vim
+--- echo matchend("testing", "ing", 5)
--- <result is "-1".
--- When {expr} is a |List| the result is equal to |match()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->matchend('word')
+--- <
---
--- @param expr any
--- @param pat any
@@ -5879,25 +6017,25 @@ function vim.fn.matchend(expr, pat, start, count) end
--- Refer to |fuzzy-matching| for more information about fuzzy
--- matching strings.
---
---- Example: >
---- :echo matchfuzzy(["clay", "crow"], "cay")
---- <results in ["clay"]. >
---- :echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
---- <results in a list of buffer names fuzzy matching "ndl". >
---- :echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
+--- Example: >vim
+--- echo matchfuzzy(["clay", "crow"], "cay")
+--- <results in ["clay"]. >vim
+--- echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
+--- <results in a list of buffer names fuzzy matching "ndl". >vim
+--- echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
--- <results in a list of buffer information dicts with buffer
---- names fuzzy matching "ndl". >
---- :echo getbufinfo()->matchfuzzy("spl",
+--- names fuzzy matching "ndl". >vim
+--- echo getbufinfo()->matchfuzzy("spl",
--- \ {'text_cb' : {v -> v.name}})
--- <results in a list of buffer information dicts with buffer
---- names fuzzy matching "spl". >
---- :echo v:oldfiles->matchfuzzy("test")
---- <results in a list of file names fuzzy matching "test". >
---- :let l = readfile("buffer.c")->matchfuzzy("str")
---- <results in a list of lines in "buffer.c" fuzzy matching "str". >
---- :echo ['one two', 'two one']->matchfuzzy('two one')
---- <results in `['two one', 'one two']` . >
---- :echo ['one two', 'two one']->matchfuzzy('two one',
+--- names fuzzy matching "spl". >vim
+--- echo v:oldfiles->matchfuzzy("test")
+--- <results in a list of file names fuzzy matching "test". >vim
+--- let l = readfile("buffer.c")->matchfuzzy("str")
+--- <results in a list of lines in "buffer.c" fuzzy matching "str". >vim
+--- echo ['one two', 'two one']->matchfuzzy('two one')
+--- <results in `['two one', 'one two']` . >vim
+--- echo ['one two', 'two one']->matchfuzzy('two one',
--- \ {'matchseq': 1})
--- <results in `['two one']`.
---
@@ -5919,12 +6057,12 @@ function vim.fn.matchfuzzy(list, str, dict) end
--- If there are no matching strings or there is an error, then a
--- list with three empty list items is returned.
---
---- Example: >
---- :echo matchfuzzypos(['testing'], 'tsg')
---- <results in [["testing"], [[0, 2, 6]], [99]] >
---- :echo matchfuzzypos(['clay', 'lacy'], 'la')
---- <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >
---- :echo [{'text': 'hello', 'id' : 10}]
+--- Example: >vim
+--- echo matchfuzzypos(['testing'], 'tsg')
+--- <results in [["testing"], [[0, 2, 6]], [99]] >vim
+--- echo matchfuzzypos(['clay', 'lacy'], 'la')
+--- <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
+--- echo [{'text': 'hello', 'id' : 10}]
--- \ ->matchfuzzypos('ll', {'key' : 'text'})
--- <results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
---
@@ -5938,15 +6076,16 @@ function vim.fn.matchfuzzypos(list, str, dict) end
--- list is the matched string, same as what matchstr() would
--- return. Following items are submatches, like "\1", "\2", etc.
--- in |:substitute|. When an optional submatch didn't match an
---- empty string is used. Example: >
+--- empty string is used. Example: >vim
--- echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
--- <Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
--- When there is no match an empty list is returned.
---
--- You can pass in a List, but that is not very useful.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->matchlist('word')
+--- <
---
--- @param expr any
--- @param pat any
@@ -5955,20 +6094,21 @@ function vim.fn.matchfuzzypos(list, str, dict) end
--- @return any
function vim.fn.matchlist(expr, pat, start, count) end
---- Same as |match()|, but return the matched string. Example: >
---- :echo matchstr("testing", "ing")
+--- Same as |match()|, but return the matched string. Example: >vim
+--- echo matchstr("testing", "ing")
--- <results in "ing".
--- When there is no match "" is returned.
---- The {start}, if given, has the same meaning as for |match()|. >
---- :echo matchstr("testing", "ing", 2)
---- <results in "ing". >
---- :echo matchstr("testing", "ing", 5)
+--- The {start}, if given, has the same meaning as for |match()|. >vim
+--- echo matchstr("testing", "ing", 2)
+--- <results in "ing". >vim
+--- echo matchstr("testing", "ing", 5)
--- <result is "".
--- When {expr} is a |List| then the matching item is returned.
--- The type isn't changed, it's not necessarily a String.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->matchstr('word')
+--- <
---
--- @param expr any
--- @param pat any
@@ -5978,23 +6118,23 @@ function vim.fn.matchlist(expr, pat, start, count) end
function vim.fn.matchstr(expr, pat, start, count) end
--- Same as |matchstr()|, but return the matched string, the start
---- position and the end position of the match. Example: >
---- :echo matchstrpos("testing", "ing")
+--- position and the end position of the match. Example: >vim
+--- echo matchstrpos("testing", "ing")
--- <results in ["ing", 4, 7].
--- When there is no match ["", -1, -1] is returned.
---- The {start}, if given, has the same meaning as for |match()|. >
---- :echo matchstrpos("testing", "ing", 2)
---- <results in ["ing", 4, 7]. >
---- :echo matchstrpos("testing", "ing", 5)
+--- The {start}, if given, has the same meaning as for |match()|. >vim
+--- echo matchstrpos("testing", "ing", 2)
+--- <results in ["ing", 4, 7]. >vim
+--- echo matchstrpos("testing", "ing", 5)
--- <result is ["", -1, -1].
--- When {expr} is a |List| then the matching item, the index
--- of first item where {pat} matches, the start position and the
---- end position of the match are returned. >
---- :echo matchstrpos([1, '__x'], '\a')
+--- end position of the match are returned. >vim
+--- echo matchstrpos([1, '__x'], '\a')
--- <result is ["x", 1, 2, 3].
--- The type isn't changed, it's not necessarily a String.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->matchstrpos('word')
--- <
---
@@ -6005,7 +6145,7 @@ function vim.fn.matchstr(expr, pat, start, count) end
--- @return any
function vim.fn.matchstrpos(expr, pat, start, count) end
---- Return the maximum value of all items in {expr}. Example: >
+--- Return the maximum value of all items in {expr}. Example: >vim
--- echo max([apples, pears, oranges])
---
--- <{expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -6014,7 +6154,7 @@ function vim.fn.matchstrpos(expr, pat, start, count) end
--- items in {expr} cannot be used as a Number this results in
--- an error. An empty |List| or |Dictionary| results in zero.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->max()
--- <
---
@@ -6026,14 +6166,14 @@ function vim.fn.max(expr) end
--- by |:menu|, |:amenu|, …), including |hidden-menus|.
---
--- {path} matches a menu by name, or all menus if {path} is an
---- empty string. Example: >
---- :echo menu_get('File','')
---- :echo menu_get('')
+--- empty string. Example: >vim
+--- echo menu_get('File','')
+--- echo menu_get('')
--- <
--- {modes} is a string of zero or more modes (see |maparg()| or
--- |creating-menus| for the list of modes). "a" means "all".
---
---- Example: >
+--- Example: >vim
--- nnoremenu &Test.Test inormal
--- inoremenu Test.Test insert
--- vnoremenu Test.Test x
@@ -6123,9 +6263,9 @@ function vim.fn.menu_get(path, modes) end
---
--- Returns an empty dictionary if the menu item is not found.
---
---- Examples: >
---- :echo menu_info('Edit.Cut')
---- :echo menu_info('File.Save', 'n')
+--- Examples: >vim
+--- echo menu_info('Edit.Cut')
+--- echo menu_info('File.Save', 'n')
---
--- " Display the entire menu hierarchy in a buffer
--- func ShowMenu(name, pfx)
@@ -6141,7 +6281,7 @@ function vim.fn.menu_get(path, modes) end
--- call ShowMenu(topmenu, '')
--- endfor
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMenuName()->menu_info('v')
--- <
---
@@ -6150,7 +6290,7 @@ function vim.fn.menu_get(path, modes) end
--- @return any
function vim.fn.menu_info(name, mode) end
---- Return the minimum value of all items in {expr}. Example: >
+--- Return the minimum value of all items in {expr}. Example: >vim
--- echo min([apples, pears, oranges])
---
--- <{expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -6159,7 +6299,7 @@ function vim.fn.menu_info(name, mode) end
--- items in {expr} cannot be used as a Number this results in
--- an error. An empty |List| or |Dictionary| results in zero.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->min()
--- <
---
@@ -6176,19 +6316,19 @@ function vim.fn.min(expr) end
--- created as necessary.
---
--- If {flags} contains "D" then {name} is deleted at the end of
---- the current function, as with: >
+--- the current function, as with: >vim
--- defer delete({name}, 'd')
--- <
--- If {flags} contains "R" then {name} is deleted recursively at
---- the end of the current function, as with: >
+--- the end of the current function, as with: >vim
--- defer delete({name}, 'rf')
--- <Note that when {name} has more than one part and "p" is used
--- some directories may already exist. Only the first one that
--- is created and what it contains is scheduled to be deleted.
---- E.g. when using: >
+--- E.g. when using: >vim
--- call mkdir('subdir/tmp/autoload', 'pR')
--- <and "subdir" already exists then "subdir/tmp" will be
---- scheduled for deletion, like with: >
+--- scheduled for deletion, like with: >vim
--- defer delete('subdir/tmp', 'rf')
--- <
--- If {prot} is given it is used to set the protection bits of
@@ -6197,8 +6337,8 @@ function vim.fn.min(expr) end
--- unreadable for others.
---
--- {prot} is applied for all parts of {name}. Thus if you create
---- /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >
---- :call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
+--- /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
+--- call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
---
--- <This function is not available in the |sandbox|.
---
@@ -6209,7 +6349,7 @@ function vim.fn.min(expr) end
--- successful or FALSE if the directory creation failed or partly
--- failed.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->mkdir()
--- <
---
@@ -6269,17 +6409,18 @@ function vim.fn.mkdir(name, flags, prot) end
--- the leading character(s).
--- Also see |visualmode()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- DoFull()->mode()
+--- <
---
--- @return any
function vim.fn.mode() end
--- Convert a list of Vimscript objects to msgpack. Returned value is a
--- |readfile()|-style list. When {type} contains "B", a |Blob| is
---- returned instead. Example: >
+--- returned instead. Example: >vim
--- call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
---- <or, using a |Blob|: >
+--- <or, using a |Blob|: >vim
--- call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
--- <
--- This will write the single 0x80 byte to a `fname.mpack` file
@@ -6300,7 +6441,7 @@ function vim.fn.msgpackdump(list, type) end
--- Convert a |readfile()|-style list or a |Blob| to a list of
--- Vimscript objects.
---- Example: >
+--- Example: >vim
--- let fname = expand('~/.config/nvim/shada/main.shada')
--- let mpack = readfile(fname, 'b')
--- let shada_objects = msgpackparse(mpack)
@@ -6376,34 +6517,36 @@ function vim.fn.msgpackdump(list, type) end
function vim.fn.msgpackparse(data) end
--- Return the line number of the first line at or below {lnum}
---- that is not blank. Example: >
---- if getline(nextnonblank(1)) =~ "Java"
+--- that is not blank. Example: >vim
+--- if getline(nextnonblank(1)) =~ "Java" | endif
--- <When {lnum} is invalid or there is no non-blank line at or
--- below it, zero is returned.
--- {lnum} is used like with |getline()|.
--- See also |prevnonblank()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->nextnonblank()
+--- <
---
--- @param lnum integer
--- @return any
function vim.fn.nextnonblank(lnum) end
--- Return a string with a single character, which has the number
---- value {expr}. Examples: >
---- nr2char(64) returns "\@"
---- nr2char(32) returns " "
---- <Example for "utf-8": >
---- nr2char(300) returns I with bow character
---- <UTF-8 encoding is always used, {utf8} option has no effect,
+--- value {expr}. Examples: >vim
+--- echo nr2char(64) " returns '\@'
+--- echo nr2char(32) " returns ' '
+--- <Example for "utf-8": >vim
+--- echo nr2char(300) " returns I with bow character
+--- <
+--- UTF-8 encoding is always used, {utf8} option has no effect,
--- and exists only for backwards-compatibility.
--- Note that a NUL character in the file is specified with
--- nr2char(10), because NULs are represented with newline
--- characters. nr2char(0) is a real NUL and terminates the
--- string, thus results in an empty string.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetNumber()->nr2char()
--- <
---
@@ -6415,10 +6558,10 @@ function vim.fn.nr2char(expr, utf8) end
--- Bitwise OR on the two arguments. The arguments are converted
--- to a number. A List, Dict or Float argument causes an error.
--- Also see `and()` and `xor()`.
---- Example: >
---- :let bits = or(bits, 0x80)
---- <Can also be used as a |method|: >
---- :let bits = bits->or(0x80)
+--- Example: >vim
+--- let bits = or(bits, 0x80)
+--- <Can also be used as a |method|: >vim
+--- let bits = bits->or(0x80)
---
--- <Rationale: The reason this is a function and not using the "|"
--- character like many languages, is that Vi has always used "|"
@@ -6434,17 +6577,18 @@ vim.fn['or'] = function(expr, expr1) end
--- result. The tail, the file name, is kept as-is. The other
--- components in the path are reduced to {len} letters in length.
--- If {len} is omitted or smaller than 1 then 1 is used (single
---- letters). Leading '~' and '.' characters are kept. Examples: >
---- :echo pathshorten('~/.config/nvim/autoload/file1.vim')
+--- letters). Leading '~' and '.' characters are kept. Examples: >vim
+--- echo pathshorten('~/.config/nvim/autoload/file1.vim')
--- < ~/.c/n/a/file1.vim ~
---- >
---- :echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
+--- >vim
+--- echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
--- < ~/.co/nv/au/file2.vim ~
--- It doesn't matter if the path exists or not.
--- Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetDirectories()->pathshorten()
+--- <
---
--- @param path string
--- @param len? any
@@ -6461,12 +6605,13 @@ function vim.fn.pathshorten(path, len) end
---
--- Note: If you want an array or hash, {expr} must return a
--- reference to it.
---- Example: >
---- :echo perleval('[1 .. 4]')
+--- Example: >vim
+--- echo perleval('[1 .. 4]')
--- < [1, 2, 3, 4]
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetExpr()->perleval()
+--- <
---
--- @param expr any
--- @return any
@@ -6475,16 +6620,17 @@ function vim.fn.perleval(expr) end
--- Return the power of {x} to the exponent {y} as a |Float|.
--- {x} and {y} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
---- Examples: >
---- :echo pow(3, 3)
---- < 27.0 >
---- :echo pow(2, 16)
---- < 65536.0 >
---- :echo pow(32, 0.20)
+--- Examples: >vim
+--- echo pow(3, 3)
+--- < 27.0 >vim
+--- echo pow(2, 16)
+--- < 65536.0 >vim
+--- echo pow(32, 0.20)
--- < 2.0
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->pow(3)
+--- <
---
--- @param x any
--- @param y any
@@ -6492,28 +6638,29 @@ function vim.fn.perleval(expr) end
function vim.fn.pow(x, y) end
--- Return the line number of the first line at or above {lnum}
---- that is not blank. Example: >
+--- that is not blank. Example: >vim
--- let ind = indent(prevnonblank(v:lnum - 1))
--- <When {lnum} is invalid or there is no non-blank line at or
--- above it, zero is returned.
--- {lnum} is used like with |getline()|.
--- Also see |nextnonblank()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetLnum()->prevnonblank()
+--- <
---
--- @param lnum integer
--- @return any
function vim.fn.prevnonblank(lnum) end
--- Return a String with {fmt}, where "%" items are replaced by
---- the formatted form of their respective arguments. Example: >
---- printf("%4d: E%d %.30s", lnum, errno, msg)
+--- the formatted form of their respective arguments. Example: >vim
+--- echo printf("%4d: E%d %.30s", lnum, errno, msg)
--- <May result in:
--- " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
---
--- When used as a |method| the base is passed as the second
---- argument: >
+--- argument: >vim
--- Compute()->printf("result: %d")
--- <
--- You can use `call()` to pass the items as a list.
@@ -6613,8 +6760,8 @@ function vim.fn.prevnonblank(lnum) end
--- Number argument supplies the field width or precision. A
--- negative field width is treated as a left adjustment flag
--- followed by a positive field width; a negative precision is
---- treated as though it were missing. Example: >
---- :echo printf("%d: %.*s", nr, width, line)
+--- treated as though it were missing. Example: >vim
+--- echo printf("%d: %.*s", nr, width, line)
--- <This limits the length of the text used from "line" to
--- "width" bytes.
---
@@ -6669,7 +6816,7 @@ function vim.fn.prevnonblank(lnum) end
--- (out of range or dividing by zero) results in "inf"
--- or "-inf" with %f (INF or -INF with %F).
--- "0.0 / 0.0" results in "nan" with %f (NAN with %F).
---- Example: >
+--- Example: >vim
--- echo printf("%.2f", 12.115)
--- < 12.12
--- Note that roundoff depends on the system libraries.
@@ -6716,8 +6863,9 @@ function vim.fn.printf(fmt, expr1) end
--- If the buffer doesn't exist or isn't a prompt buffer, an empty
--- string is returned.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBuffer()->prompt_getprompt()
+--- <
---
--- @param buf any
--- @return any
@@ -6738,7 +6886,7 @@ function vim.fn.prompt_getprompt(buf) end
--- The callback is invoked with one argument, which is the text
--- that was entered at the prompt. This can be an empty string
--- if the user only typed Enter.
---- Example: >
+--- Example: >vim
--- func s:TextEntered(text)
--- if a:text == 'exit' || a:text == 'quit'
--- stopinsert
@@ -6754,8 +6902,9 @@ function vim.fn.prompt_getprompt(buf) end
--- endfunc
--- call prompt_setcallback(bufnr(), function('s:TextEntered'))
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetBuffer()->prompt_setcallback(callback)
+--- <
---
--- @param buf any
--- @param expr any
@@ -6770,8 +6919,9 @@ function vim.fn.prompt_setcallback(buf, expr) end
--- mode. Without setting a callback Vim will exit Insert mode,
--- as in any buffer.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBuffer()->prompt_setinterrupt(callback)
+--- <
---
--- @param buf any
--- @param expr any
@@ -6781,11 +6931,12 @@ function vim.fn.prompt_setinterrupt(buf, expr) end
--- Set prompt for buffer {buf} to {text}. You most likely want
--- {text} to end in a space.
--- The result is only visible if {buf} has 'buftype' set to
---- "prompt". Example: >
+--- "prompt". Example: >vim
--- call prompt_setprompt(bufnr(''), 'command: ')
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBuffer()->prompt_setprompt('command: ')
+--- <
---
--- @param buf any
--- @param text any
@@ -6824,7 +6975,7 @@ function vim.fn.pumvisible() end
--- Dictionaries are represented as Vim |Dictionary| type with
--- keys converted to strings.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetExpr()->py3eval()
--- <
---
@@ -6840,8 +6991,9 @@ function vim.fn.py3eval(expr) end
--- Dictionaries are represented as Vim |Dictionary| type,
--- non-string keys result in error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetExpr()->pyeval()
+--- <
---
--- @param expr any
--- @return any
@@ -6852,7 +7004,7 @@ function vim.fn.pyeval(expr) end
--- Uses Python 2 or 3, see |python_x| and 'pyxversion'.
--- See also: |pyeval()|, |py3eval()|
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetExpr()->pyxeval()
--- <
---
@@ -6868,13 +7020,13 @@ function vim.fn.pyxeval(expr) end
--- and updated.
--- Returns -1 if {expr} is invalid.
---
---- Examples: >
---- :echo rand()
---- :let seed = srand()
---- :echo rand(seed)
---- :echo rand(seed) % 16 " random number 0 - 15
+--- Examples: >vim
+--- echo rand()
+--- let seed = srand()
+--- echo rand(seed)
+--- echo rand(seed) % 16 " random number 0 - 15
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- seed->rand()
--- <
---
@@ -6891,15 +7043,15 @@ function vim.fn.rand(expr) end
--- When the maximum is one before the start the result is an
--- empty list. When the maximum is more than one before the
--- start this is an error.
---- Examples: >
---- range(4) " [0, 1, 2, 3]
---- range(2, 4) " [2, 3, 4]
---- range(2, 9, 3) " [2, 5, 8]
---- range(2, -2, -1) " [2, 1, 0, -1, -2]
---- range(0) " []
---- range(2, 0) " error!
---- <
---- Can also be used as a |method|: >
+--- Examples: >vim
+--- echo range(4) " [0, 1, 2, 3]
+--- echo range(2, 4) " [2, 3, 4]
+--- echo range(2, 9, 3) " [2, 5, 8]
+--- echo range(2, -2, -1) " [2, 1, 0, -1, -2]
+--- echo range(0) " []
+--- echo range(2, 0) " error!
+--- <
+--- Can also be used as a |method|: >vim
--- GetExpr()->range()
--- <
---
@@ -6912,18 +7064,18 @@ function vim.fn.range(expr, max, stride) end
--- Read file {fname} in binary mode and return a |Blob|.
--- If {offset} is specified, read the file from the specified
--- offset. If it is a negative value, it is used as an offset
---- from the end of the file. E.g., to read the last 12 bytes: >
---- readblob('file.bin', -12)
+--- from the end of the file. E.g., to read the last 12 bytes: >vim
+--- echo readblob('file.bin', -12)
--- <If {size} is specified, only the specified size will be read.
---- E.g. to read the first 100 bytes of a file: >
---- readblob('file.bin', 0, 100)
+--- E.g. to read the first 100 bytes of a file: >vim
+--- echo readblob('file.bin', 0, 100)
--- <If {size} is -1 or omitted, the whole data starting from
--- {offset} will be read.
--- This can be also used to read the data from a character device
--- on Unix when {size} is explicitly set. Only if the device
--- supports seeking {offset} can be used. Otherwise it should be
---- zero. E.g. to read 10 bytes from a serial console: >
---- readblob('/dev/ttyS0', 0, 10)
+--- zero. E.g. to read 10 bytes from a serial console: >vim
+--- echo readblob('/dev/ttyS0', 0, 10)
--- <When the file can't be opened an error message is given and
--- the result is an empty |Blob|.
--- When the offset is beyond the end of the file the result is an
@@ -6952,12 +7104,12 @@ function vim.fn.readblob(fname, offset, size) end
--- to the list.
--- Each time {expr} is evaluated |v:val| is set to the entry name.
--- When {expr} is a function the name is passed as the argument.
---- For example, to get a list of files ending in ".txt": >
---- readdir(dirname, {n -> n =~ '.txt$'})
---- <To skip hidden and backup files: >
---- readdir(dirname, {n -> n !~ '^\.\|\~$'})
+--- For example, to get a list of files ending in ".txt": >vim
+--- echo readdir(dirname, {n -> n =~ '.txt$'})
+--- <To skip hidden and backup files: >vim
+--- echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
---
---- <If you want to get a directory tree: >
+--- <If you want to get a directory tree: >vim
--- function! s:tree(dir)
--- return {a:dir : map(readdir(a:dir),
--- \ {_, x -> isdirectory(x) ?
@@ -6967,7 +7119,7 @@ function vim.fn.readblob(fname, offset, size) end
--- <
--- Returns an empty List on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetDirName()->readdir()
--- <
---
@@ -6991,10 +7143,10 @@ function vim.fn.readdir(directory, expr) end
--- - Any UTF-8 byte order mark is removed from the text.
--- When {max} is given this specifies the maximum number of lines
--- to be read. Useful if you only want to check the first ten
---- lines of a file: >
---- :for line in readfile(fname, '', 10)
---- : if line =~ 'Date' | echo line | endif
---- :endfor
+--- lines of a file: >vim
+--- for line in readfile(fname, '', 10)
+--- if line =~ 'Date' | echo line | endif
+--- endfor
--- <When {max} is negative -{max} lines from the end of the file
--- are returned, or as many as there are.
--- When {max} is zero the result is an empty list.
@@ -7008,7 +7160,7 @@ function vim.fn.readdir(directory, expr) end
--- the result is an empty list.
--- Also see |writefile()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFileName()->readfile()
--- <
---
@@ -7028,13 +7180,14 @@ function vim.fn.readfile(fname, type, max) end
--- item. If {initial} is not given and {object} is empty no
--- result can be computed, an E998 error is given.
---
---- Examples: >
+--- Examples: >vim
--- echo reduce([1, 3, 5], { acc, val -> acc + val })
--- echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
--- echo reduce(0z1122, { acc, val -> 2 * acc + val })
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- echo mylist->reduce({ acc, val -> acc + val }, 0)
+--- <
---
--- @param object any
--- @param func any
@@ -7086,7 +7239,7 @@ function vim.fn.reltime(start) end
--- The {start} and {end} arguments must be values returned by
--- reltime(). Returns zero on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetStart()->reltime()
--- <
--- Note: |localtime()| returns the current (non-relative) time.
@@ -7106,8 +7259,9 @@ function vim.fn.reltime(start, end_) end
--- Also see |profiling|.
--- If there is an error an empty string is returned
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- reltime(start)->reltimefloat()
+--- <
---
--- @param time any
--- @return any
@@ -7115,19 +7269,19 @@ function vim.fn.reltimefloat(time) end
--- Return a String that represents the time value of {time}.
--- This is the number of seconds, a dot and the number of
---- microseconds. Example: >
+--- microseconds. Example: >vim
--- let start = reltime()
--- call MyFunction()
--- echo reltimestr(reltime(start))
--- <Note that overhead for the commands will be added to the time.
--- Leading spaces are used to make the string align nicely. You
---- can use split() to remove it. >
+--- can use split() to remove it. >vim
--- echo split(reltimestr(reltime(start)))[0]
--- <Also see |profiling|.
--- If there is an error an empty string is returned
---
---- Can also be used as a |method|: >
---- reltime(start)->reltimestr()
+--- Can also be used as a |method|: >vim
+--- echo reltime(start)->reltimestr()
--- <
---
--- @param time any
@@ -7147,14 +7301,15 @@ function vim.fn.remove(list, idx) end
--- points to an item before {idx} this is an error.
--- See |list-index| for possible values of {idx} and {end}.
--- Returns zero on error.
---- Example: >
---- :echo "last item: " .. remove(mylist, -1)
---- :call remove(mylist, 0, 9)
+--- Example: >vim
+--- echo "last item: " .. remove(mylist, -1)
+--- call remove(mylist, 0, 9)
--- <
--- Use |delete()| to remove a file.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->remove(idx)
+--- <
---
--- @param list any
--- @param idx integer
@@ -7174,9 +7329,10 @@ function vim.fn.remove(blob, idx) end
--- byte as {end} a |Blob| with one byte is returned. When {end}
--- points to a byte before {idx} this is an error.
--- Returns zero on error.
---- Example: >
---- :echo "last byte: " .. remove(myblob, -1)
---- :call remove(mylist, 0, 9)
+--- Example: >vim
+--- echo "last byte: " .. remove(myblob, -1)
+--- call remove(mylist, 0, 9)
+--- <
---
--- @param blob any
--- @param idx integer
@@ -7185,8 +7341,8 @@ function vim.fn.remove(blob, idx) end
function vim.fn.remove(blob, idx, end_) end
--- Remove the entry from {dict} with key {key} and return it.
---- Example: >
---- :echo "removed " .. remove(dict, "one")
+--- Example: >vim
+--- echo "removed " .. remove(dict, "one")
--- <If there is no {key} in {dict} this is an error.
--- Returns zero on error.
---
@@ -7202,8 +7358,9 @@ function vim.fn.remove(dict, key) end
--- NOTE: If {to} exists it is overwritten without warning.
--- This function is not available in the |sandbox|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetOldName()->rename(newname)
+--- <
---
--- @param from any
--- @param to any
@@ -7211,15 +7368,15 @@ function vim.fn.remove(dict, key) end
function vim.fn.rename(from, to) end
--- Repeat {expr} {count} times and return the concatenated
---- result. Example: >
---- :let separator = repeat('-', 80)
+--- result. Example: >vim
+--- let separator = repeat('-', 80)
--- <When {count} is zero or negative the result is empty.
--- When {expr} is a |List| or a |Blob| the result is {expr}
---- concatenated {count} times. Example: >
---- :let longlist = repeat(['a', 'b'], 3)
+--- concatenated {count} times. Example: >vim
+--- let longlist = repeat(['a', 'b'], 3)
--- <Results in ['a', 'b', 'a', 'b', 'a', 'b'].
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->repeat(count)
--- <
---
@@ -7240,7 +7397,7 @@ vim.fn['repeat'] = function(expr, count) end
--- current directory (provided the result is still a relative
--- path name) and also keeps a trailing path separator.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->resolve()
--- <
---
@@ -7252,10 +7409,11 @@ function vim.fn.resolve(filename) end
--- {object} can be a |List| or a |Blob|.
--- Returns {object}.
--- Returns zero if {object} is not a List or a Blob.
---- If you want an object to remain unmodified make a copy first: >
---- :let revlist = reverse(copy(mylist))
---- <Can also be used as a |method|: >
+--- If you want an object to remain unmodified make a copy first: >vim
+--- let revlist = reverse(copy(mylist))
+--- <Can also be used as a |method|: >vim
--- mylist->reverse()
+--- <
---
--- @param object any
--- @return any
@@ -7266,16 +7424,17 @@ function vim.fn.reverse(object) end
--- values, then use the larger one (away from zero).
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
+--- Examples: >vim
--- echo round(0.456)
---- < 0.0 >
+--- < 0.0 >vim
--- echo round(4.5)
---- < 5.0 >
+--- < 5.0 >vim
--- echo round(-4.5)
--- < -5.0
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->round()
+--- <
---
--- @param expr any
--- @return any
@@ -7283,8 +7442,9 @@ function vim.fn.round(expr) end
--- Sends {event} to {channel} via |RPC| and returns immediately.
--- If {channel} is 0, the event is broadcast to all channels.
---- Example: >
---- :au VimLeave call rpcnotify(0, "leaving")
+--- Example: >vim
+--- au VimLeave call rpcnotify(0, "leaving")
+--- <
---
--- @param channel any
--- @param event any
@@ -7294,8 +7454,9 @@ function vim.fn.rpcnotify(channel, event, args) end
--- Sends a request to {channel} to invoke {method} via
--- |RPC| and blocks until a response is received.
---- Example: >
---- :let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
+--- Example: >vim
+--- let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
+--- <
---
--- @param channel any
--- @param method any
@@ -7303,10 +7464,11 @@ function vim.fn.rpcnotify(channel, event, args) end
--- @return any
function vim.fn.rpcrequest(channel, method, args) end
---- Deprecated. Replace >
---- :let id = rpcstart('prog', ['arg1', 'arg2'])
---- <with >
---- :let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
+--- Deprecated. Replace >vim
+--- let id = rpcstart('prog', ['arg1', 'arg2'])
+--- <with >vim
+--- let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
+--- <
---
--- @param prog any
--- @param argv? any
@@ -7332,8 +7494,9 @@ function vim.fn.rpcstop(...) end
--- Other objects are represented as strings resulted from their
--- "Object#to_s" method.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRubyExpr()->rubyeval()
+--- <
---
--- @param expr any
--- @return any
@@ -7344,8 +7507,9 @@ function vim.fn.rubyeval(expr) end
--- attribute at other positions.
--- Returns -1 when row or col is out of range.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRow()->screenattr(col)
+--- <
---
--- @param row any
--- @param col integer
@@ -7361,8 +7525,9 @@ function vim.fn.screenattr(row, col) end
--- This is mainly to be used for testing.
--- Returns -1 when row or col is out of range.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRow()->screenchar(col)
+--- <
---
--- @param row any
--- @param col integer
@@ -7375,8 +7540,9 @@ function vim.fn.screenchar(row, col) end
--- This is mainly to be used for testing.
--- Returns an empty List when row or col is out of range.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRow()->screenchars(col)
+--- <
---
--- @param row any
--- @param col integer
@@ -7391,7 +7557,7 @@ function vim.fn.screenchars(row, col) end
--- in a command (e.g. ":echo screencol()") it will return the
--- column inside the command line, which is 1 when the command is
--- executed. To get the cursor position in the file use one of
---- the following mappings: >
+--- the following mappings: >vim
--- nnoremap <expr> GG ":echom " .. screencol() .. "\n"
--- nnoremap <silent> GG :echom screencol()<CR>
--- noremap GG <Cmd>echom screencol()<Cr>
@@ -7423,8 +7589,9 @@ function vim.fn.screencol() end
--- first character is returned, {col} is not used.
--- Returns an empty Dict if {winid} is invalid.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->screenpos(lnum, col)
+--- <
---
--- @param winid integer
--- @param lnum integer
@@ -7449,7 +7616,7 @@ function vim.fn.screenrow() end
--- This is mainly to be used for testing.
--- Returns an empty String when row or col is out of range.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetRow()->screenstring(col)
--- <
---
@@ -7498,7 +7665,7 @@ function vim.fn.screenstring(row, col) end
---
--- When the {stopline} argument is given then the search stops
--- after searching this line. This is useful to restrict the
---- search to a range of lines. Examples: >
+--- search to a range of lines. Examples: >vim
--- let match = search('(', 'b', line("w0"))
--- let end = search('END', '', line("w$"))
--- <When {stopline} is used and it is not zero this also implies
@@ -7529,24 +7696,24 @@ function vim.fn.screenstring(row, col) end
--- The cursor will be positioned at the match, unless the 'n'
--- flag is used.
---
---- Example (goes over all files in the argument list): >
---- :let n = 1
---- :while n <= argc() " loop over all files in arglist
---- : exe "argument " .. n
---- : " start at the last char in the file and wrap for the
---- : " first search to find match at start of file
---- : normal G$
---- : let flags = "w"
---- : while search("foo", flags) > 0
---- : s/foo/bar/g
---- : let flags = "W"
---- : endwhile
---- : update " write the file if modified
---- : let n = n + 1
---- :endwhile
---- <
---- Example for using some flags: >
---- :echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
+--- Example (goes over all files in the argument list): >vim
+--- let n = 1
+--- while n <= argc() " loop over all files in arglist
+--- exe "argument " .. n
+--- " start at the last char in the file and wrap for the
+--- " first search to find match at start of file
+--- normal G$
+--- let flags = "w"
+--- while search("foo", flags) > 0
+--- s/foo/bar/g
+--- let flags = "W"
+--- endwhile
+--- update " write the file if modified
+--- let n = n + 1
+--- endwhile
+--- <
+--- Example for using some flags: >vim
+--- echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
--- <This will search for the keywords "if", "else", and "endif"
--- under or after the cursor. Because of the 'p' flag, it
--- returns 1, 2, or 3 depending on which keyword is found, or 0
@@ -7558,8 +7725,9 @@ function vim.fn.screenstring(row, col) end
--- without the 'e' flag if the cursor is on the "f" of "if".
--- The 'n' flag tells the function not to move the cursor.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPattern()->search()
+--- <
---
--- @param pattern any
--- @param flags? string
@@ -7593,7 +7761,7 @@ function vim.fn.search(pattern, flags, stopline, timeout, skip) end
--- this function with `recompute: 0` . This sometimes returns
--- wrong information because |n| and |N|'s maximum count is 99.
--- If it exceeded 99 the result must be max count + 1 (100). If
---- you want to get correct information, specify `recompute: 1`: >
+--- you want to get correct information, specify `recompute: 1`: >vim
---
--- " result == maxcount + 1 (100) when many matches
--- let result = searchcount(#{recompute: 0})
@@ -7602,7 +7770,7 @@ function vim.fn.search(pattern, flags, stopline, timeout, skip) end
--- " to 1)
--- let result = searchcount()
--- <
---- The function is useful to add the count to 'statusline': >
+--- The function is useful to add the count to 'statusline': >vim
--- function! LastSearchCount() abort
--- let result = searchcount(#{recompute: 0})
--- if empty(result)
@@ -7631,7 +7799,7 @@ function vim.fn.search(pattern, flags, stopline, timeout, skip) end
--- " \ '%{v:hlsearch ? LastSearchCount() : ""}'
--- <
--- You can also update the search count, which can be useful in a
---- |CursorMoved| or |CursorMovedI| autocommand: >
+--- |CursorMoved| or |CursorMovedI| autocommand: >vim
---
--- autocmd CursorMoved,CursorMovedI *
--- \ let s:searchcount_timer = timer_start(
@@ -7645,7 +7813,7 @@ function vim.fn.search(pattern, flags, stopline, timeout, skip) end
--- endfunction
--- <
--- This can also be used to count matched texts with specified
---- pattern in the current buffer using "pattern": >
+--- pattern in the current buffer using "pattern": >vim
---
--- " Count '\<foo\>' in this buffer
--- " (Note that it also updates search count)
@@ -7669,7 +7837,7 @@ function vim.fn.search(pattern, flags, stopline, timeout, skip) end
--- and different with |\@/|.
--- this works as same as the
--- below command is executed
---- before calling this function >
+--- before calling this function >vim
--- let \@/ = pattern
--- < (default: |\@/|)
--- timeout |Number| 0 or negative number is no
@@ -7689,7 +7857,7 @@ function vim.fn.search(pattern, flags, stopline, timeout, skip) end
--- value. see |cursor()|, |getpos()|
--- (default: cursor's position)
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSearchOpts()->searchcount()
--- <
---
@@ -7709,12 +7877,12 @@ function vim.fn.searchcount(options) end
---
--- Moves the cursor to the found match.
--- Returns zero for success, non-zero for failure.
---- Example: >
+--- Example: >vim
--- if searchdecl('myvar') == 0
--- echo getline('.')
--- endif
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->searchdecl()
--- <
---
@@ -7738,8 +7906,8 @@ function vim.fn.searchdecl(name, global, thisblock) end
--- must not contain \( \) pairs. Use of \%( \) is allowed. When
--- {middle} is not empty, it is found when searching from either
--- direction, but only when not in a nested start-end pair. A
---- typical use is: >
---- searchpair('\<if\>', '\<else\>', '\<endif\>')
+--- typical use is: >vim
+--- echo searchpair('\<if\>', '\<else\>', '\<endif\>')
--- <By leaving {middle} empty the "else" is skipped.
---
--- {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
@@ -7769,7 +7937,7 @@ function vim.fn.searchdecl(name, global, thisblock) end
---
--- The search starts exactly at the cursor. A match with
--- {start}, {middle} or {end} at the next character, in the
---- direction of searching, is the first one found. Example: >
+--- direction of searching, is the first one found. Example: >vim
--- if 1
--- if 2
--- endif 2
@@ -7785,9 +7953,9 @@ function vim.fn.searchdecl(name, global, thisblock) end
--- that when the cursor is inside a match with the end it finds
--- the matching start.
---
---- Example, to find the "endif" command in a Vim script: >
+--- Example, to find the "endif" command in a Vim script: >vim
---
---- :echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
+--- echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
--- \ 'getline(".") =~ "^\\s*\""')
---
--- <The cursor must be at or after the "if" for which a match is
@@ -7796,15 +7964,15 @@ function vim.fn.searchdecl(name, global, thisblock) end
--- catches comments at the start of a line, not after a command.
--- Also, a word "en" or "if" halfway through a line is considered
--- a match.
---- Another example, to search for the matching "{" of a "}": >
+--- Another example, to search for the matching "{" of a "}": >vim
---
---- :echo searchpair('{', '', '}', 'bW')
+--- echo searchpair('{', '', '}', 'bW')
---
--- <This works when the cursor is at or before the "}" for which a
--- match is to be found. To reject matches that syntax
---- highlighting recognized as strings: >
+--- highlighting recognized as strings: >vim
---
---- :echo searchpair('{', '', '}', 'bW',
+--- echo searchpair('{', '', '}', 'bW',
--- \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
--- <
---
@@ -7815,9 +7983,9 @@ function vim.fn.searchpair() end
--- column position of the match. The first element of the |List|
--- is the line number and the second element is the byte index of
--- the column position of the match. If no match is found,
---- returns [0, 0]. >
+--- returns [0, 0]. >vim
---
---- :let [lnum,col] = searchpairpos('{', '', '}', 'n')
+--- let [lnum,col] = searchpairpos('{', '', '}', 'n')
--- <
--- See |match-parens| for a bigger and more useful example.
---
@@ -7829,17 +7997,18 @@ function vim.fn.searchpairpos() end
--- is the line number and the second element is the byte index of
--- the column position of the match. If no match is found,
--- returns [0, 0].
---- Example: >
---- :let [lnum, col] = searchpos('mypattern', 'n')
+--- Example: >vim
+--- let [lnum, col] = searchpos('mypattern', 'n')
---
--- <When the 'p' flag is given then there is an extra item with
---- the sub-pattern match number |search()-sub-match|. Example: >
---- :let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
+--- the sub-pattern match number |search()-sub-match|. Example: >vim
+--- let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
--- <In this example "submatch" is 2 when a lowercase letter is
--- found |/\l|, 3 when an uppercase letter is found |/\u|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPattern()->searchpos()
+--- <
---
--- @param pattern any
--- @param flags? string
@@ -7851,8 +8020,9 @@ function vim.fn.searchpos(pattern, flags, stopline, timeout, skip) end
--- Returns a list of server addresses, or empty if all servers
--- were stopped. |serverstart()| |serverstop()|
---- Example: >
---- :echo serverlist()
+--- Example: >vim
+--- echo serverlist()
+--- <
---
--- @return any
function vim.fn.serverlist() end
@@ -7869,24 +8039,26 @@ function vim.fn.serverlist() end
--- assigns a random port).
--- - Else {address} is the path to a named pipe (except on Windows).
--- - If {address} has no slashes ("/") it is treated as the
---- "name" part of a generated path in this format: >
+--- "name" part of a generated path in this format: >vim
--- stdpath("run").."/{name}.{pid}.{counter}"
---- < - If {address} is omitted the name is "nvim". >
---- :echo serverstart()
+--- < - If {address} is omitted the name is "nvim". >vim
+--- echo serverstart()
+--- < >
--- => /tmp/nvim.bram/oknANW/nvim.15430.5
----
---- <Example bash command to list all Nvim servers: >
+--- <
+--- Example bash command to list all Nvim servers: >bash
--- ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
---
---- <Example named pipe: >
+--- <Example named pipe: >vim
--- if has('win32')
--- echo serverstart('\\.\pipe\nvim-pipe-1234')
--- else
--- echo serverstart('nvim.sock')
--- endif
--- <
---- Example TCP/IP address: >
+--- Example TCP/IP address: >vim
--- echo serverstart('::1:12345')
+--- <
---
--- @param address? any
--- @return any
@@ -7925,8 +8097,9 @@ function vim.fn.serverstop(address) end
--- error message is given.
---
--- Can also be used as a |method|, the base is passed as the
---- third argument: >
+--- third argument: >vim
--- GetText()->setbufline(buf, lnum)
+--- <
---
--- @param buf any
--- @param lnum integer
@@ -7942,13 +8115,13 @@ function vim.fn.setbufline(buf, lnum, text) end
--- For the use of {buf}, see |bufname()| above.
--- The {varname} argument is a string.
--- Note that the variable name without "b:" must be used.
---- Examples: >
---- :call setbufvar(1, "&mod", 1)
---- :call setbufvar("todo", "myvar", "foobar")
+--- Examples: >vim
+--- call setbufvar(1, "&mod", 1)
+--- call setbufvar("todo", "myvar", "foobar")
--- <This function is not available in the |sandbox|.
---
--- Can also be used as a |method|, the base is passed as the
---- third argument: >
+--- third argument: >vim
--- GetValue()->setbufvar(buf, varname)
--- <
---
@@ -7961,7 +8134,7 @@ function vim.fn.setbufvar(buf, varname, val) end
--- Specify overrides for cell widths of character ranges. This
--- tells Vim how wide characters are when displayed in the
--- terminal, counted in screen cells. The values override
---- 'ambiwidth'. Example: >
+--- 'ambiwidth'. Example: >vim
--- call setcellwidths([
--- \ [0x111, 0x111, 1],
--- \ [0x2194, 0x2199, 2],
@@ -7982,7 +8155,7 @@ function vim.fn.setbufvar(buf, varname, val) end
--- If the new value causes 'fillchars' or 'listchars' to become
--- invalid it is rejected and an error is given.
---
---- To clear the overrides pass an empty {list}: >
+--- To clear the overrides pass an empty {list}: >vim
--- call setcellwidths([])
---
--- <You can use the script $VIMRUNTIME/tools/emoji_list.vim to see
@@ -7999,14 +8172,15 @@ function vim.fn.setcellwidths(list) end
--- character index instead of the byte index in the line.
---
--- Example:
---- With the text "μ—¬λ³΄μ„Έμš”" in line 8: >
+--- With the text "μ—¬λ³΄μ„Έμš”" in line 8: >vim
--- call setcharpos('.', [0, 8, 4, 0])
---- <positions the cursor on the fourth character 'μš”'. >
+--- <positions the cursor on the fourth character 'μš”'. >vim
--- call setpos('.', [0, 8, 4, 0])
--- <positions the cursor on the second character '보'.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPosition()->setcharpos('.')
+--- <
---
--- @param expr any
--- @param list any
@@ -8026,14 +8200,15 @@ function vim.fn.setcharpos(expr, list) end
--- character search
---
--- This can be useful to save/restore a user's character search
---- from a script: >
---- :let prevsearch = getcharsearch()
---- :" Perform a command which clobbers user's search
---- :call setcharsearch(prevsearch)
+--- from a script: >vim
+--- let prevsearch = getcharsearch()
+--- " Perform a command which clobbers user's search
+--- call setcharsearch(prevsearch)
--- <Also see |getcharsearch()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- SavedSearch()->setcharsearch()
+--- <
---
--- @param dict any
--- @return any
@@ -8045,8 +8220,9 @@ function vim.fn.setcharsearch(dict) end
--- Returns 0 when successful, 1 when not editing the command
--- line.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->setcmdline()
+--- <
---
--- @param str any
--- @param pos? any
@@ -8067,8 +8243,9 @@ function vim.fn.setcmdline(str, pos) end
--- Returns 0 when successful, 1 when not editing the command
--- line.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPos()->setcmdpos()
+--- <
---
--- @param pos any
--- @return any
@@ -8084,27 +8261,28 @@ function vim.fn.setcursorcharpos(lnum, col, off) end
--- character index instead of the byte index in the line.
---
--- Example:
---- With the text "μ—¬λ³΄μ„Έμš”" in line 4: >
+--- With the text "μ—¬λ³΄μ„Έμš”" in line 4: >vim
--- call setcursorcharpos(4, 3)
---- <positions the cursor on the third character 'μ„Έ'. >
+--- <positions the cursor on the third character 'μ„Έ'. >vim
--- call cursor(4, 3)
--- <positions the cursor on the first character 'μ—¬'.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCursorPos()->setcursorcharpos()
+--- <
---
--- @param list any
--- @return any
function vim.fn.setcursorcharpos(list) end
---- Set environment variable {name} to {val}. Example: >
+--- Set environment variable {name} to {val}. Example: >vim
--- call setenv('HOME', '/home/myhome')
---
--- <When {val} is |v:null| the environment variable is deleted.
--- See also |expr-env|.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetPath()->setenv('PATH')
--- <
---
@@ -8127,7 +8305,7 @@ function vim.fn.setenv(name, val) end
---
--- Returns non-zero for success, zero for failure.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFilename()->setfperm(mode)
--- <
--- To read permissions see |getfperm()|.
@@ -8150,22 +8328,23 @@ function vim.fn.setfperm(fname, mode) end
--- If this succeeds, FALSE is returned. If this fails (most likely
--- because {lnum} is invalid) TRUE is returned.
---
---- Example: >
---- :call setline(5, strftime("%c"))
+--- Example: >vim
+--- call setline(5, strftime("%c"))
---
--- <When {text} is a |List| then line {lnum} and following lines
---- will be set to the items in the list. Example: >
---- :call setline(5, ['aaa', 'bbb', 'ccc'])
---- <This is equivalent to: >
---- :for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
---- : call setline(n, l)
---- :endfor
+--- will be set to the items in the list. Example: >vim
+--- call setline(5, ['aaa', 'bbb', 'ccc'])
+--- <This is equivalent to: >vim
+--- for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
+--- call setline(n, l)
+--- endfor
---
--- <Note: The '[ and '] marks are not set.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetText()->setline(lnum)
+--- <
---
--- @param lnum integer
--- @param text any
@@ -8188,8 +8367,9 @@ function vim.fn.setline(lnum, text) end
--- for the list of supported keys in {what}.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetLoclist()->setloclist(winnr)
+--- <
---
--- @param nr integer
--- @param list any
@@ -8205,7 +8385,7 @@ function vim.fn.setloclist(nr, list, action, what) end
--- If {win} is specified, use the window with this number or
--- window ID instead of the current window.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMatches()->setmatches()
--- <
---
@@ -8262,8 +8442,9 @@ function vim.fn.setmatches(list, win) end
--- also set the preferred column. Also see the "curswant" key in
--- |winrestview()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetPosition()->setpos('.')
+--- <
---
--- @param expr any
--- @param list any
@@ -8322,8 +8503,8 @@ function vim.fn.setpos(expr, list) end
---
--- 'r' The items from the current quickfix list are replaced
--- with the items from {list}. This can also be used to
---- clear the list: >
---- :call setqflist([], 'r')
+--- clear the list: >vim
+--- call setqflist([], 'r')
--- <
--- 'f' All the quickfix lists in the quickfix stack are
--- freed.
@@ -8369,10 +8550,10 @@ function vim.fn.setpos(expr, list) end
--- list is modified, "id" should be used instead of "nr" to
--- specify the list.
---
---- Examples (See also |setqflist-examples|): >
---- :call setqflist([], 'r', {'title': 'My search'})
---- :call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
---- :call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
+--- Examples (See also |setqflist-examples|): >vim
+--- call setqflist([], 'r', {'title': 'My search'})
+--- call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
+--- call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
--- <
--- Returns zero for success, -1 for failure.
---
@@ -8381,7 +8562,7 @@ function vim.fn.setpos(expr, list) end
--- `:cc 1` to jump to the first position.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetErrorlist()->setqflist()
--- <
---
@@ -8422,33 +8603,34 @@ function vim.fn.setqflist(list, action, what) end
--- set search and expression registers. Lists containing no
--- items act like empty strings.
---
---- Examples: >
---- :call setreg(v:register, \@*)
---- :call setreg('*', \@%, 'ac')
---- :call setreg('a', "1\n2\n3", 'b5')
---- :call setreg('"', { 'points_to': 'a'})
+--- Examples: >vim
+--- call setreg(v:register, \@*)
+--- call setreg('*', \@%, 'ac')
+--- call setreg('a', "1\n2\n3", 'b5')
+--- call setreg('"', { 'points_to': 'a'})
---
--- <This example shows using the functions to save and restore a
---- register: >
---- :let var_a = getreginfo()
---- :call setreg('a', var_a)
---- <or: >
---- :let var_a = getreg('a', 1, 1)
---- :let var_amode = getregtype('a')
---- ....
---- :call setreg('a', var_a, var_amode)
+--- register: >vim
+--- let var_a = getreginfo()
+--- call setreg('a', var_a)
+--- <or: >vim
+--- let var_a = getreg('a', 1, 1)
+--- let var_amode = getregtype('a')
+--- " ....
+--- call setreg('a', var_a, var_amode)
--- <Note: you may not reliably restore register value
--- without using the third argument to |getreg()| as without it
--- newlines are represented as newlines AND Nul bytes are
--- represented as newlines as well, see |NL-used-for-Nul|.
---
--- You can also change the type of a register by appending
---- nothing: >
---- :call setreg('a', '', 'al')
+--- nothing: >vim
+--- call setreg('a', '', 'al')
---
--- <Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetText()->setreg('a')
+--- <
---
--- @param regname string
--- @param value any
@@ -8464,8 +8646,9 @@ function vim.fn.setreg(regname, value, options) end
--- This function is not available in the |sandbox|.
---
--- Can also be used as a |method|, the base is passed as the
---- third argument: >
+--- third argument: >vim
--- GetValue()->settabvar(tab, name)
+--- <
---
--- @param tabnr integer
--- @param varname string
@@ -8483,14 +8666,15 @@ function vim.fn.settabvar(tabnr, varname, val) end
--- doesn't work for a global or local buffer variable.
--- For a local buffer option the global value is unchanged.
--- Note that the variable name without "w:" must be used.
---- Examples: >
---- :call settabwinvar(1, 1, "&list", 0)
---- :call settabwinvar(3, 2, "myvar", "foobar")
+--- Examples: >vim
+--- call settabwinvar(1, 1, "&list", 0)
+--- call settabwinvar(3, 2, "myvar", "foobar")
--- <This function is not available in the |sandbox|.
---
--- Can also be used as a |method|, the base is passed as the
---- fourth argument: >
+--- fourth argument: >vim
--- GetValue()->settabwinvar(tab, winnr, name)
+--- <
---
--- @param tabnr integer
--- @param winnr integer
@@ -8522,18 +8706,19 @@ function vim.fn.settabwinvar(tabnr, winnr, varname, val) end
--- Returns zero for success, -1 for failure.
---
--- Examples (for more examples see |tagstack-examples|):
---- Empty the tag stack of window 3: >
+--- Empty the tag stack of window 3: >vim
--- call settagstack(3, {'items' : []})
---
---- < Save and restore the tag stack: >
+--- < Save and restore the tag stack: >vim
--- let stack = gettagstack(1003)
--- " do something else
--- call settagstack(1003, stack)
--- unlet stack
--- <
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetStack()->settagstack(winnr)
+--- <
---
--- @param nr integer
--- @param dict any
@@ -8542,13 +8727,14 @@ function vim.fn.settabwinvar(tabnr, winnr, varname, val) end
function vim.fn.settagstack(nr, dict, action) end
--- Like |settabwinvar()| for the current tab page.
---- Examples: >
---- :call setwinvar(1, "&list", 0)
---- :call setwinvar(2, "myvar", "foobar")
+--- Examples: >vim
+--- call setwinvar(1, "&list", 0)
+--- call setwinvar(2, "myvar", "foobar")
---
--- <Can also be used as a |method|, the base is passed as the
---- third argument: >
+--- third argument: >vim
--- GetValue()->setwinvar(winnr, name)
+--- <
---
--- @param nr integer
--- @param varname string
@@ -8559,8 +8745,9 @@ function vim.fn.setwinvar(nr, varname, val) end
--- Returns a String with 64 hex characters, which is the SHA256
--- checksum of {string}.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->sha256()
+--- <
---
--- @param string string
--- @return any
@@ -8589,15 +8776,16 @@ function vim.fn.sha256(string) end
--- be escaped because in fish it is used as an escape character
--- inside single quotes.
---
---- Example of use with a |:!| command: >
---- :exe '!dir ' .. shellescape(expand('<cfile>'), 1)
+--- Example of use with a |:!| command: >vim
+--- exe '!dir ' .. shellescape(expand('<cfile>'), 1)
--- <This results in a directory listing for the file under the
---- cursor. Example of use with |system()|: >
---- :call system("chmod +w -- " .. shellescape(expand("%")))
+--- cursor. Example of use with |system()|: >vim
+--- call system("chmod +w -- " .. shellescape(expand("%")))
--- <See also |::S|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetCommand()->shellescape()
+--- <
---
--- @param string string
--- @param special? any
@@ -8607,7 +8795,7 @@ function vim.fn.shellescape(string, special) end
--- Returns the effective value of 'shiftwidth'. This is the
--- 'shiftwidth' value unless it is zero, in which case it is the
--- 'tabstop' value. To be backwards compatible in indent
---- plugins, use this: >
+--- plugins, use this: >vim
--- if exists('*shiftwidth')
--- func s:sw()
--- return shiftwidth()
@@ -8624,10 +8812,9 @@ function vim.fn.shellescape(string, special) end
--- 'vartabstop' feature. If no {col} argument is given, column 1
--- will be assumed.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetColumn()->shiftwidth()
----
---- sign_ functions are documented here: |sign-functions-details|
+--- <
---
--- @param col? integer
--- @return any
@@ -8670,7 +8857,7 @@ function vim.fn.sign_define(name, dict) end
--- {list} is used, then returns a List of values one for each
--- defined sign.
---
---- Examples: >
+--- Examples: >vim
--- call sign_define("mySign", {
--- \ "text" : "=>",
--- \ "texthl" : "Error",
@@ -8682,8 +8869,9 @@ function vim.fn.sign_define(name, dict) end
--- \ 'text' : '!!'}
--- \ ])
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSignList()->sign_define()
+--- <
---
--- @param list any
--- @return any
@@ -8716,15 +8904,16 @@ function vim.fn.sign_define(list) end
--- Returns an empty List if there are no signs and when {name} is
--- not found.
---
---- Examples: >
+--- Examples: >vim
--- " Get a list of all the defined signs
--- echo sign_getdefined()
---
--- " Get the attribute of the sign named mySign
--- echo sign_getdefined("mySign")
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSignList()->sign_getdefined()
+--- <
---
--- @param name? string
--- @return any
@@ -8768,7 +8957,7 @@ function vim.fn.sign_getdefined(name) end
--- Returns an empty list on failure or if there are no placed
--- signs.
---
---- Examples: >
+--- Examples: >vim
--- " Get a List of signs placed in eval.c in the
--- " global group
--- echo sign_getplaced("eval.c")
@@ -8789,7 +8978,7 @@ function vim.fn.sign_getdefined(name) end
--- " Get a List of all the placed signs
--- echo sign_getplaced()
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBufname()->sign_getplaced()
--- <
---
@@ -8808,11 +8997,11 @@ function vim.fn.sign_getplaced(buf, dict) end
--- Returns the line number of the sign. Returns -1 if the
--- arguments are invalid.
---
---- Example: >
+--- Example: >vim
--- " Jump to sign 10 in the current buffer
--- call sign_jump(10, '', '')
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSignid()->sign_jump()
--- <
---
@@ -8850,7 +9039,7 @@ function vim.fn.sign_jump(id, group, buf) end
---
--- Returns the sign identifier on success and -1 on failure.
---
---- Examples: >
+--- Examples: >vim
--- " Place a sign named sign1 with id 5 at line 20 in
--- " buffer json.c
--- call sign_place(5, '', 'sign1', 'json.c',
@@ -8869,7 +9058,7 @@ function vim.fn.sign_jump(id, group, buf) end
--- call sign_place(10, 'g3', 'sign4', 'json.c',
--- \ {'lnum' : 40, 'priority' : 90})
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSignid()->sign_place(group, name, expr)
--- <
---
@@ -8913,7 +9102,7 @@ function vim.fn.sign_place(id, group, name, buf, dict) end
--- Returns a List of sign identifiers. If failed to place a
--- sign, the corresponding list item is set to -1.
---
---- Examples: >
+--- Examples: >vim
--- " Place sign s1 with id 5 at line 20 and id 10 at line
--- " 30 in buffer a.c
--- let [n1, n2] = sign_placelist([
@@ -8938,8 +9127,9 @@ function vim.fn.sign_place(id, group, name, buf, dict) end
--- \ 'lnum' : 50}
--- \ ])
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSignlist()->sign_placelist()
+--- <
---
--- @param list any
--- @return any
@@ -8960,7 +9150,7 @@ function vim.fn.sign_undefine(name) end
--- {list} call, returns a list of values one for each undefined
--- sign.
---
---- Examples: >
+--- Examples: >vim
--- " Delete a sign named mySign
--- call sign_undefine("mySign")
---
@@ -8970,8 +9160,9 @@ function vim.fn.sign_undefine(name) end
--- " Delete all the signs
--- call sign_undefine()
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSignlist()->sign_undefine()
+--- <
---
--- @param list? any
--- @return any
@@ -8993,7 +9184,7 @@ function vim.fn.sign_undefine(list) end
---
--- Returns 0 on success and -1 on failure.
---
---- Examples: >
+--- Examples: >vim
--- " Remove sign 10 from buffer a.vim
--- call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
---
@@ -9018,7 +9209,7 @@ function vim.fn.sign_undefine(list) end
--- " Remove all the placed signs from all the buffers
--- call sign_unplace('*')
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetSigngroup()->sign_unplace()
--- <
---
@@ -9046,7 +9237,7 @@ function vim.fn.sign_unplace(group, dict) end
--- Returns a List where an entry is set to 0 if the corresponding
--- sign was successfully removed or -1 on failure.
---
---- Example: >
+--- Example: >vim
--- " Remove sign with id 10 from buffer a.vim and sign
--- " with id 20 from buffer b.vim
--- call sign_unplacelist([
@@ -9054,7 +9245,7 @@ function vim.fn.sign_unplace(group, dict) end
--- \ {'id' : 20, 'buffer' : 'b.vim'},
--- \ ])
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetSignlist()->sign_unplacelist()
--- <
---
@@ -9070,7 +9261,7 @@ function vim.fn.sign_unplacelist(list) end
--- not removed either. On Unix "//path" is unchanged, but
--- "///path" is simplified to "/path" (this follows the Posix
--- standard).
---- Example: >
+--- Example: >vim
--- simplify("./dir/.././/file/") == "./file/"
--- <Note: The combination "dir/.." is only removed if "dir" is
--- a searchable directory or does not exist. On Unix, it is also
@@ -9078,8 +9269,9 @@ function vim.fn.sign_unplacelist(list) end
--- directory. In order to resolve all the involved symbolic
--- links before simplifying the path name, use |resolve()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetName()->simplify()
+--- <
---
--- @param filename any
--- @return any
@@ -9088,14 +9280,15 @@ function vim.fn.simplify(filename) end
--- Return the sine of {expr}, measured in radians, as a |Float|.
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo sin(100)
---- < -0.506366 >
---- :echo sin(-4.01)
+--- Examples: >vim
+--- echo sin(100)
+--- < -0.506366 >vim
+--- echo sin(-4.01)
--- < 0.763301
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->sin()
+--- <
---
--- @param expr any
--- @return any
@@ -9105,14 +9298,15 @@ function vim.fn.sin(expr) end
--- [-inf, inf].
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo sinh(0.5)
---- < 0.521095 >
---- :echo sinh(-0.9)
+--- Examples: >vim
+--- echo sinh(0.5)
+--- < 0.521095 >vim
+--- echo sinh(-0.9)
--- < -1.026517
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->sinh()
+--- <
---
--- @param expr any
--- @return any
@@ -9126,7 +9320,7 @@ function vim.fn.sinh(expr) end
--- When {end} is -1 the last item is omitted.
--- Returns an empty value if {start} or {end} are invalid.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetList()->slice(offset)
--- <
---
@@ -9168,8 +9362,8 @@ function vim.fn.sockconnect(mode, address, opts) end
--- Sort the items in {list} in-place. Returns {list}.
---
---- If you want a list to remain unmodified make a copy first: >
---- :let sortedlist = sort(copy(mylist))
+--- If you want a list to remain unmodified make a copy first: >vim
+--- let sortedlist = sort(copy(mylist))
---
--- <When {func} is omitted, is empty or zero, then sort() uses the
--- string representation of each item to sort on. Numbers sort
@@ -9184,15 +9378,15 @@ function vim.fn.sockconnect(mode, address, opts) end
--- is used to compare strings. See |:language| check or set the
--- collation locale. |v:collate| can also be used to check the
--- current locale. Sorting using the locale typically ignores
---- case. Example: >
+--- case. Example: >vim
--- " ΓΆ is sorted similarly to o with English locale.
---- :language collate en_US.UTF8
---- :echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
+--- language collate en_US.UTF8
+--- echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
--- < ['n', 'o', 'O', 'ΓΆ', 'p', 'z'] ~
---- >
+--- >vim
--- " ΓΆ is sorted after z with Swedish locale.
---- :language collate sv_SE.UTF8
---- :echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
+--- language collate sv_SE.UTF8
+--- echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
--- < ['n', 'o', 'O', 'p', 'z', 'ΓΆ'] ~
--- This does not work properly on Mac.
---
@@ -9222,22 +9416,22 @@ function vim.fn.sockconnect(mode, address, opts) end
--- on numbers, text strings will sort next to each other, in the
--- same order as they were originally.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->sort()
---
--- <Also see |uniq()|.
---
---- Example: >
+--- Example: >vim
--- func MyCompare(i1, i2)
--- return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
--- endfunc
--- eval mylist->sort("MyCompare")
--- <A shorter compare version for this specific simple case, which
---- ignores overflow: >
+--- ignores overflow: >vim
--- func MyCompare(i1, i2)
--- return a:i1 - a:i2
--- endfunc
---- <For a simple expression you can use a lambda: >
+--- <For a simple expression you can use a lambda: >vim
--- eval mylist->sort({i1, i2 -> i1 - i2})
--- <
---
@@ -9254,7 +9448,7 @@ function vim.fn.sort(list, func, dict) end
--- This can be used for making spelling suggestions. Note that
--- the method can be quite slow.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWord()->soundfold()
--- <
---
@@ -9278,14 +9472,14 @@ function vim.fn.soundfold(word) end
--- "rare" rare word
--- "local" word only valid in another region
--- "caps" word should start with Capital
---- Example: >
+--- Example: >vim
--- echo spellbadword("the quik brown fox")
--- < ['quik', 'bad'] ~
---
--- The spelling information for the current window and the value
--- of 'spelllang' are used.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->spellbadword()
--- <
---
@@ -9313,8 +9507,9 @@ function vim.fn.spellbadword(sentence) end
--- The spelling information for the current window is used. The
--- values of 'spelllang' and 'spellsuggest' are used.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWord()->spellsuggest()
+--- <
---
--- @param word any
--- @param max? any
@@ -9332,20 +9527,23 @@ function vim.fn.spellsuggest(word, max, capital) end
--- {keepempty} argument is given and it's non-zero.
--- Other empty items are kept when {pattern} matches at least one
--- character or when {keepempty} is non-zero.
---- Example: >
---- :let words = split(getline('.'), '\W\+')
---- <To split a string in individual characters: >
---- :for c in split(mystring, '\zs')
+--- Example: >vim
+--- let words = split(getline('.'), '\W\+')
+--- <To split a string in individual characters: >vim
+--- for c in split(mystring, '\zs') | endfor
--- <If you want to keep the separator you can also use '\zs' at
---- the end of the pattern: >
---- :echo split('abc:def:ghi', ':\zs')
---- < ['abc:', 'def:', 'ghi'] ~
---- Splitting a table where the first element can be empty: >
---- :let items = split(line, ':', 1)
+--- the end of the pattern: >vim
+--- echo split('abc:def:ghi', ':\zs')
+--- < >
+--- ['abc:', 'def:', 'ghi']
+--- <
+--- Splitting a table where the first element can be empty: >vim
+--- let items = split(line, ':', 1)
--- <The opposite function is |join()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetString()->split()
+--- <
---
--- @param string string
--- @param pattern? any
@@ -9358,15 +9556,16 @@ function vim.fn.split(string, pattern, keepempty) end
--- {expr} must evaluate to a |Float| or a |Number|. When {expr}
--- is negative the result is NaN (Not a Number). Returns 0.0 if
--- {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo sqrt(100)
---- < 10.0 >
---- :echo sqrt(-4.01)
+--- Examples: >vim
+--- echo sqrt(100)
+--- < 10.0 >vim
+--- echo sqrt(-4.01)
--- < str2float("nan")
--- NaN may be different, it depends on system libraries.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->sqrt()
+--- <
---
--- @param expr any
--- @return any
@@ -9380,13 +9579,14 @@ function vim.fn.sqrt(expr) end
--- initialize the seed values. This is useful for testing or
--- when a predictable sequence is intended.
---
---- Examples: >
---- :let seed = srand()
---- :let seed = srand(userinput)
---- :echo rand(seed)
+--- Examples: >vim
+--- let seed = srand()
+--- let seed = srand(userinput)
+--- echo rand(seed)
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- userinput->srand()
+--- <
---
--- @param expr? any
--- @return any
@@ -9433,8 +9633,8 @@ function vim.fn.stdioopen(opts) end
--- state String Session state directory: storage for file
--- drafts, swap, undo, |shada|.
---
---- Example: >
---- :echo stdpath("config")
+--- Example: >vim
+--- echo stdpath("config")
--- <
---
--- @param what any
@@ -9454,13 +9654,14 @@ function vim.fn.stdpath(what) end
--- The decimal point is always '.', no matter what the locale is
--- set to. A comma ends the number: "12,345.67" is converted to
--- 12.0. You can strip out thousands separators with
---- |substitute()|: >
+--- |substitute()|: >vim
--- let f = str2float(substitute(text, ',', '', 'g'))
--- <
--- Returns 0.0 if the conversion fails.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- let f = text->substitute(',', '', 'g')->str2float()
+--- <
---
--- @param string string
--- @param quoted? any
@@ -9468,18 +9669,19 @@ function vim.fn.stdpath(what) end
function vim.fn.str2float(string, quoted) end
--- Return a list containing the number values which represent
---- each character in String {string}. Examples: >
---- str2list(" ") returns [32]
---- str2list("ABC") returns [65, 66, 67]
+--- each character in String {string}. Examples: >vim
+--- echo str2list(" ") " returns [32]
+--- echo str2list("ABC") " returns [65, 66, 67]
--- <|list2str()| does the opposite.
---
--- UTF-8 encoding is always used, {utf8} option has no effect,
--- and exists only for backwards-compatibility.
---- With UTF-8 composing characters are handled properly: >
---- str2list("á") returns [97, 769]
+--- With UTF-8 composing characters are handled properly: >vim
+--- echo str2list("á") " returns [97, 769]
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetString()->str2list()
+--- <
---
--- @param string string
--- @param utf8? any
@@ -9493,7 +9695,7 @@ function vim.fn.str2list(string, utf8) end
---
--- When {base} is omitted base 10 is used. This also means that
--- a leading zero doesn't cause octal conversion to be used, as
---- with the default String to Number conversion. Example: >
+--- with the default String to Number conversion. Example: >vim
--- let nr = str2nr('0123')
--- <
--- When {base} is 16 a leading "0x" or "0X" is ignored. With a
@@ -9504,7 +9706,7 @@ function vim.fn.str2list(string, utf8) end
---
--- Returns 0 if {string} is empty or on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->str2nr()
--- <
---
@@ -9522,7 +9724,7 @@ function vim.fn.str2nr(string, base) end
---
--- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->strcharlen()
--- <
---
@@ -9538,13 +9740,13 @@ function vim.fn.strcharlen(string) end
--- similar to |slice()|.
--- When a character index is used where a character does not
--- exist it is omitted and counted as one character. For
---- example: >
---- strcharpart('abc', -1, 2)
+--- example: >vim
+--- echo strcharpart('abc', -1, 2)
--- <results in 'a'.
---
--- Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->strcharpart(5)
--- <
---
@@ -9567,7 +9769,7 @@ function vim.fn.strcharpart(src, start, len, skipcc) end
--- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
---
--- {skipcc} is only available after 7.4.755. For backward
---- compatibility, you can define a wrapper function: >
+--- compatibility, you can define a wrapper function: >vim
--- if has("patch-7.4.755")
--- function s:strchars(str, skipcc)
--- return strchars(a:str, a:skipcc)
@@ -9582,8 +9784,9 @@ function vim.fn.strcharpart(src, start, len, skipcc) end
--- endfunction
--- endif
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->strchars()
+--- <
---
--- @param string string
--- @param skipcc? any
@@ -9603,8 +9806,9 @@ function vim.fn.strchars(string, skipcc) end
--- Returns zero on error.
--- Also see |strlen()|, |strwidth()| and |strchars()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->strdisplaywidth()
+--- <
---
--- @param string string
--- @param col? integer
@@ -9619,16 +9823,17 @@ function vim.fn.strdisplaywidth(string, col) end
--- format. The maximum length of the result is 80 characters.
--- See also |localtime()|, |getftime()| and |strptime()|.
--- The language can be changed with the |:language| command.
---- Examples: >
---- :echo strftime("%c") Sun Apr 27 11:49:23 1997
---- :echo strftime("%Y %b %d %X") 1997 Apr 27 11:53:25
---- :echo strftime("%y%m%d %T") 970427 11:53:55
---- :echo strftime("%H:%M") 11:55
---- :echo strftime("%c", getftime("file.c"))
---- Show mod time of file.c.
----
---- <Can also be used as a |method|: >
+--- Examples: >vim
+--- echo strftime("%c") " Sun Apr 27 11:49:23 1997
+--- echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
+--- echo strftime("%y%m%d %T") " 970427 11:53:55
+--- echo strftime("%H:%M") " 11:55
+--- echo strftime("%c", getftime("file.c"))
+--- " Show mod time of file.c.
+---
+--- <Can also be used as a |method|: >vim
--- GetFormat()->strftime()
+--- <
---
--- @param format any
--- @param time? any
@@ -9643,8 +9848,9 @@ function vim.fn.strftime(format, time) end
--- Returns -1 if {index} is invalid.
--- Also see |strcharpart()| and |strchars()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->strgetchar(5)
+--- <
---
--- @param str any
--- @param index any
@@ -9654,22 +9860,22 @@ function vim.fn.strgetchar(str, index) end
--- The result is a Number, which gives the byte index in
--- {haystack} of the first occurrence of the String {needle}.
--- If {start} is specified, the search starts at index {start}.
---- This can be used to find a second match: >
---- :let colon1 = stridx(line, ":")
---- :let colon2 = stridx(line, ":", colon1 + 1)
+--- This can be used to find a second match: >vim
+--- let colon1 = stridx(line, ":")
+--- let colon2 = stridx(line, ":", colon1 + 1)
--- <The search is done case-sensitive.
--- For pattern searches use |match()|.
--- -1 is returned if the {needle} does not occur in {haystack}.
--- See also |strridx()|.
---- Examples: >
---- :echo stridx("An Example", "Example") 3
---- :echo stridx("Starting point", "Start") 0
---- :echo stridx("Starting point", "start") -1
+--- Examples: >vim
+--- echo stridx("An Example", "Example") " 3
+--- echo stridx("Starting point", "Start") " 0
+--- echo stridx("Starting point", "start") " -1
--- < *strstr()* *strchr()*
--- stridx() works similar to the C function strstr(). When used
--- with a single character it works similar to strchr().
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetHaystack()->stridx(needle)
--- <
---
@@ -9702,8 +9908,9 @@ function vim.fn.stridx(haystack, needle, start) end
--- method, use |msgpackdump()| or |json_encode()| if you need to
--- share data with other application.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->string()
+--- <
---
--- @param expr any
--- @return any
@@ -9717,8 +9924,9 @@ function vim.fn.string(expr) end
--- |strchars()|.
--- Also see |len()|, |strdisplaywidth()| and |strwidth()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetString()->strlen()
+--- <
---
--- @param string string
--- @return any
@@ -9736,20 +9944,21 @@ function vim.fn.strlen(string) end
--- When bytes are selected which do not exist, this doesn't
--- result in an error, the bytes are simply omitted.
--- If {len} is missing, the copy continues from {start} till the
---- end of the {src}. >
---- strpart("abcdefg", 3, 2) == "de"
---- strpart("abcdefg", -2, 4) == "ab"
---- strpart("abcdefg", 5, 4) == "fg"
---- strpart("abcdefg", 3) == "defg"
+--- end of the {src}. >vim
+--- echo strpart("abcdefg", 3, 2) " returns 'de'
+--- echo strpart("abcdefg", -2, 4) " returns 'ab'
+--- echo strpart("abcdefg", 5, 4) " returns 'fg'
+--- echo strpart("abcdefg", 3) " returns 'defg'
---
--- <Note: To get the first character, {start} must be 0. For
---- example, to get the character under the cursor: >
+--- example, to get the character under the cursor: >vim
--- strpart(getline("."), col(".") - 1, 1, v:true)
--- <
--- Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->strpart(5)
+--- <
---
--- @param src any
--- @param start any
@@ -9773,15 +9982,15 @@ function vim.fn.strpart(src, start, len, chars) end
--- result.
---
--- See also |strftime()|.
---- Examples: >
---- :echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
---- < 862156163 >
---- :echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
---- < Sun Apr 27 11:53:55 1997 >
---- :echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
+--- Examples: >vim
+--- echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
+--- < 862156163 >vim
+--- echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
+--- < Sun Apr 27 11:53:55 1997 >vim
+--- echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
--- < Sun Apr 27 12:53:55 1997
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFormat()->strptime(timestring)
--- <
---
@@ -9794,21 +10003,22 @@ function vim.fn.strptime(format, timestring) end
--- {haystack} of the last occurrence of the String {needle}.
--- When {start} is specified, matches beyond this index are
--- ignored. This can be used to find a match before a previous
---- match: >
---- :let lastcomma = strridx(line, ",")
---- :let comma2 = strridx(line, ",", lastcomma - 1)
+--- match: >vim
+--- let lastcomma = strridx(line, ",")
+--- let comma2 = strridx(line, ",", lastcomma - 1)
--- <The search is done case-sensitive.
--- For pattern searches use |match()|.
--- -1 is returned if the {needle} does not occur in {haystack}.
--- If the {needle} is empty the length of {haystack} is returned.
---- See also |stridx()|. Examples: >
---- :echo strridx("an angry armadillo", "an") 3
+--- See also |stridx()|. Examples: >vim
+--- echo strridx("an angry armadillo", "an") 3
--- < *strrchr()*
--- When used with a single character it works similar to the C
--- function strrchr().
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetHaystack()->strridx(needle)
+--- <
---
--- @param haystack any
--- @param needle any
@@ -9818,15 +10028,16 @@ function vim.fn.strridx(haystack, needle, start) end
--- The result is a String, which is {string} with all unprintable
--- characters translated into printable characters |'isprint'|.
---- Like they are shown in a window. Example: >
+--- Like they are shown in a window. Example: >vim
--- echo strtrans(\@a)
--- <This displays a newline in register a as "^\@" instead of
--- starting a new line.
---
--- Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetString()->strtrans()
+--- <
---
--- @param string string
--- @return any
@@ -9843,14 +10054,14 @@ function vim.fn.strtrans(string) end
--- Returns zero on error.
---
--- Also see |strlen()| and |strcharlen()|.
---- Examples: >
---- echo strutf16len('a') returns 1
---- echo strutf16len('Β©') returns 1
---- echo strutf16len('😊') returns 2
---- echo strutf16len('ą́') returns 1
---- echo strutf16len('ą́', v:true) returns 3
----
---- Can also be used as a |method|: >
+--- Examples: >vim
+--- echo strutf16len('a') " returns 1
+--- echo strutf16len('Β©') " returns 1
+--- echo strutf16len('😊') " returns 2
+--- echo strutf16len('ą́') " returns 1
+--- echo strutf16len('ą́', v:true) " returns 3
+---
+--- Can also be used as a |method|: >vim
--- GetText()->strutf16len()
--- <
---
@@ -9867,8 +10078,9 @@ function vim.fn.strutf16len(string, countcc) end
--- Returns zero on error.
--- Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetString()->strwidth()
+--- <
---
--- @param string string
--- @return any
@@ -9895,14 +10107,15 @@ function vim.fn.strwidth(string) end
---
--- Returns an empty string or list on error.
---
---- Examples: >
---- :s/\d\+/\=submatch(0) + 1/
---- :echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
+--- Examples: >vim
+--- s/\d\+/\=submatch(0) + 1/
+--- echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
--- <This finds the first number in the line and adds one to it.
--- A line break is included as a newline character.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetNr()->submatch()
+--- <
---
--- @param nr integer
--- @param list? any
@@ -9930,29 +10143,30 @@ function vim.fn.submatch(nr, list) end
--- When {pat} does not match in {string}, {string} is returned
--- unmodified.
---
---- Example: >
---- :let &path = substitute(&path, ",\\=[^,]*$", "", "")
---- <This removes the last component of the 'path' option. >
---- :echo substitute("testing", ".*", "\\U\\0", "")
+--- Example: >vim
+--- let &path = substitute(&path, ",\\=[^,]*$", "", "")
+--- <This removes the last component of the 'path' option. >vim
+--- echo substitute("testing", ".*", "\\U\\0", "")
--- <results in "TESTING".
---
--- When {sub} starts with "\=", the remainder is interpreted as
---- an expression. See |sub-replace-expression|. Example: >
---- :echo substitute(s, '%\(\x\x\)',
+--- an expression. See |sub-replace-expression|. Example: >vim
+--- echo substitute(s, '%\(\x\x\)',
--- \ '\=nr2char("0x" .. submatch(1))', 'g')
---
--- <When {sub} is a Funcref that function is called, with one
---- optional argument. Example: >
---- :echo substitute(s, '%\(\x\x\)', SubNr, 'g')
+--- optional argument. Example: >vim
+--- echo substitute(s, '%\(\x\x\)', SubNr, 'g')
--- <The optional argument is a list which contains the whole
--- matched string and up to nine submatches, like what
---- |submatch()| returns. Example: >
---- :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
+--- |submatch()| returns. Example: >vim
+--- echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
---
--- <Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetString()->substitute(pat, sub, flags)
+--- <
---
--- @param string string
--- @param pat any
@@ -9965,7 +10179,7 @@ function vim.fn.substitute(string, pat, sub, flags) end
--- See the |-r| command argument. The 'directory' option is used
--- for the directories to inspect. If you only want to get a
--- list of swap files in the current directory then temporarily
---- set 'directory' to a dot: >
+--- set 'directory' to a dot: >vim
--- let save_dir = &directory
--- let &directory = '.'
--- let swapfiles = swapfilelist()
@@ -9991,8 +10205,9 @@ function vim.fn.swapfilelist() end
--- Not a swap file: does not contain correct block ID
--- Magic number mismatch: Info in first block is invalid
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFilename()->swapinfo()
+--- <
---
--- @param fname integer
--- @return any
@@ -10004,8 +10219,9 @@ function vim.fn.swapinfo(fname) end
--- |:swapname| (unless there is no swap file).
--- If buffer {buf} has no swap file, returns an empty string.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBufname()->swapname()
+--- <
---
--- @param buf any
--- @return any
@@ -10032,8 +10248,8 @@ function vim.fn.swapname(buf) end
---
--- Returns zero on error.
---
---- Example (echoes the name of the syntax item under the cursor): >
---- :echo synIDattr(synID(line("."), col("."), 1), "name")
+--- Example (echoes the name of the syntax item under the cursor): >vim
+--- echo synIDattr(synID(line("."), col("."), 1), "name")
--- <
---
--- @param lnum integer
@@ -10080,11 +10296,12 @@ function vim.fn.synID(lnum, col, trans) end
--- Returns an empty string on error.
---
--- Example (echoes the color of the syntax item under the
---- cursor): >
---- :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
+--- cursor): >vim
+--- echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
+--- <
+--- Can also be used as a |method|: >vim
+--- echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
--- <
---- Can also be used as a |method|: >
---- :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
---
--- @param synID any
--- @param what any
@@ -10099,8 +10316,9 @@ function vim.fn.synIDattr(synID, what, mode) end
---
--- Returns zero on error.
---
---- Can also be used as a |method|: >
---- :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
+--- Can also be used as a |method|: >vim
+--- echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
+--- <
---
--- @param synID any
--- @return any
@@ -10145,7 +10363,7 @@ function vim.fn.synconcealed(lnum, col) end
--- returns, unless not the whole item is highlighted or it is a
--- transparent item.
--- This function is useful for debugging a syntax file.
---- Example that shows the syntax stack under the cursor: >
+--- Example that shows the syntax stack under the cursor: >vim
--- for id in synstack(line("."), col("."))
--- echo synIDattr(id, "name")
--- endfor
@@ -10165,8 +10383,8 @@ function vim.fn.synstack(lnum, col) end
--- a |List|) and sets |v:shell_error| to the error code.
--- {cmd} is treated as in |jobstart()|:
--- If {cmd} is a List it runs directly (no 'shell').
---- If {cmd} is a String it runs in the 'shell', like this: >
---- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+--- If {cmd} is a String it runs in the 'shell', like this: >vim
+--- call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
---
--- <Not to be used for interactive commands.
---
@@ -10174,8 +10392,8 @@ function vim.fn.synstack(lnum, col) end
--- - <CR><NL> is replaced with <NL>
--- - NUL characters are replaced with SOH (0x01)
---
---- Example: >
---- :echo system(['ls', expand('%:h')])
+--- Example: >vim
+--- echo system(['ls', expand('%:h')])
---
--- <If {input} is a string it is written to a pipe and passed as
--- stdin to the command. The string is written as-is, line
@@ -10189,8 +10407,8 @@ function vim.fn.synstack(lnum, col) end
--- terminated by NL (and NUL where the text has NL).
--- *E5677*
--- Note: system() cannot write to or read from backgrounded ("&")
---- shell commands, e.g.: >
---- :echo system("cat - &", "foo")
+--- shell commands, e.g.: >vim
+--- echo system("cat - &", "foo")
--- <which is equivalent to: >
--- $ echo foo | bash -c 'cat - &'
--- <The pipes are disconnected (unless overridden by shell
@@ -10200,15 +10418,16 @@ function vim.fn.synstack(lnum, col) end
--- Note: Use |shellescape()| or |::S| with |expand()| or
--- |fnamemodify()| to escape special characters in a command
--- argument. 'shellquote' and 'shellxquote' must be properly
---- configured. Example: >
---- :echo system('ls '..shellescape(expand('%:h')))
---- :echo system('ls '..expand('%:h:S'))
+--- configured. Example: >vim
+--- echo system('ls '..shellescape(expand('%:h')))
+--- echo system('ls '..expand('%:h:S'))
---
--- <Unlike ":!cmd" there is no automatic check for changed files.
--- Use |:checktime| to force a check.
---
---- Can also be used as a |method|: >
---- :echo GetCmd()->system()
+--- Can also be used as a |method|: >vim
+--- echo GetCmd()->system()
+--- <
---
--- @param cmd any
--- @param input? any
@@ -10223,13 +10442,14 @@ function vim.fn.system(cmd, input) end
--- Note that on MS-Windows you may get trailing CR characters.
---
--- To see the difference between "echo hello" and "echo -n hello"
---- use |system()| and |split()|: >
+--- use |system()| and |split()|: >vim
--- echo split(system('echo hello'), '\n', 1)
--- <
--- Returns an empty string on error.
---
---- Can also be used as a |method|: >
---- :echo GetCmd()->systemlist()
+--- Can also be used as a |method|: >vim
+--- echo GetCmd()->systemlist()
+--- <
---
--- @param cmd any
--- @param input? any
@@ -10242,15 +10462,16 @@ function vim.fn.systemlist(cmd, input, keepempty) end
--- {arg} specifies the number of the tab page to be used. When
--- omitted the current tab page is used.
--- When {arg} is invalid the number zero is returned.
---- To get a list of all buffers in all tabs use this: >
+--- To get a list of all buffers in all tabs use this: >vim
--- let buflist = []
--- for i in range(tabpagenr('$'))
--- call extend(buflist, tabpagebuflist(i + 1))
--- endfor
--- <Note that a buffer may appear in more than one window.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTabpage()->tabpagebuflist()
+--- <
---
--- @param arg? any
--- @return any
@@ -10280,12 +10501,12 @@ function vim.fn.tabpagenr(arg) end
--- the window which will be used when going to this tab page.
--- - When "$" the number of windows is returned.
--- - When "#" the previous window nr is returned.
---- Useful examples: >
+--- Useful examples: >vim
--- tabpagewinnr(1) " current window of tab page 1
--- tabpagewinnr(4, '$') " number of windows in tab page 4
--- <When {tabarg} is invalid zero is returned.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTabpage()->tabpagewinnr()
--- <
---
@@ -10342,7 +10563,7 @@ function vim.fn.tagfiles() end
--- located by Vim. Refer to |tags-file-format| for the format of
--- the tags file generated by the different ctags tools.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTagpattern()->taglist()
---
--- @param expr any
@@ -10354,14 +10575,15 @@ function vim.fn.taglist(expr, filename) end
--- in the range [-inf, inf].
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo tan(10)
---- < 0.648361 >
---- :echo tan(-4.01)
+--- Examples: >vim
+--- echo tan(10)
+--- < 0.648361 >vim
+--- echo tan(-4.01)
--- < -1.181502
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->tan()
+--- <
---
--- @param expr any
--- @return any
@@ -10371,13 +10593,13 @@ function vim.fn.tan(expr) end
--- range [-1, 1].
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
---- :echo tanh(0.5)
---- < 0.462117 >
---- :echo tanh(-1)
+--- Examples: >vim
+--- echo tanh(0.5)
+--- < 0.462117 >vim
+--- echo tanh(-1)
--- < -0.761594
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->tanh()
--- <
---
@@ -10387,9 +10609,10 @@ function vim.fn.tanh(expr) end
--- Generates a (non-existent) filename located in the Nvim root
--- |tempdir|. Scripts can use the filename as a temporary file.
---- Example: >
---- :let tmpfile = tempname()
---- :exe "redir > " .. tmpfile
+--- Example: >vim
+--- let tmpfile = tempname()
+--- exe "redir > " .. tmpfile
+--- <
---
--- @return string
function vim.fn.tempname() end
@@ -10427,7 +10650,7 @@ function vim.fn.termopen(cmd, opts) end
--- -1 means forever
--- "callback" the callback
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTimer()->timer_info()
--- <
---
@@ -10447,7 +10670,7 @@ function vim.fn.timer_info(id) end
--- String, then the timer is paused, otherwise it is unpaused.
--- See |non-zero-arg|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTimer()->timer_pause(1)
--- <
---
@@ -10477,7 +10700,7 @@ function vim.fn.timer_pause(timer, paused) end
---
--- Returns -1 on error.
---
---- Example: >
+--- Example: >vim
--- func MyHandler(timer)
--- echo 'Handler called'
--- endfunc
@@ -10485,7 +10708,7 @@ function vim.fn.timer_pause(timer, paused) end
--- \ {'repeat': 3})
--- <This invokes MyHandler() three times at 500 msec intervals.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetMsec()->timer_start(callback)
---
--- <Not available in the |sandbox|.
@@ -10500,7 +10723,7 @@ function vim.fn.timer_start(time, callback, options) end
--- {timer} is an ID returned by timer_start(), thus it must be a
--- Number. If {timer} does not exist there is no error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTimer()->timer_stop()
--- <
---
@@ -10519,8 +10742,9 @@ function vim.fn.timer_stopall() end
--- characters turned into lowercase (just like applying |gu| to
--- the string). Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->tolower()
+--- <
---
--- @param expr any
--- @return string
@@ -10530,8 +10754,9 @@ function vim.fn.tolower(expr) end
--- characters turned into uppercase (just like applying |gU| to
--- the string). Returns an empty string on error.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->toupper()
+--- <
---
--- @param expr any
--- @return string
@@ -10546,14 +10771,15 @@ function vim.fn.toupper(expr) end
---
--- Returns an empty string on error.
---
---- Examples: >
+--- Examples: >vim
--- echo tr("hello there", "ht", "HT")
---- <returns "Hello THere" >
+--- <returns "Hello THere" >vim
--- echo tr("<blob>", "<>", "{}")
--- <returns "{blob}"
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->tr(from, to)
+--- <
---
--- @param src any
--- @param fromstr any
@@ -10575,18 +10801,19 @@ function vim.fn.tr(src, fromstr, tostr) end
--- This function deals with multibyte characters properly.
--- Returns an empty string on error.
---
---- Examples: >
+--- Examples: >vim
--- echo trim(" some text ")
---- <returns "some text" >
+--- <returns "some text" >vim
--- echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
---- <returns "RESERVE_TAIL" >
+--- <returns "RESERVE_TAIL" >vim
--- echo trim("rm<Xrm<>X>rrm", "rm<>")
---- <returns "Xrm<>X" (characters in the middle are not removed) >
+--- <returns "Xrm<>X" (characters in the middle are not removed) >vim
--- echo trim(" vim ", " ", 2)
--- <returns " vim"
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetText()->trim()
+--- <
---
--- @param text any
--- @param mask? any
@@ -10598,16 +10825,17 @@ function vim.fn.trim(text, mask, dir) end
--- equal to {expr} as a |Float| (truncate towards zero).
--- {expr} must evaluate to a |Float| or a |Number|.
--- Returns 0.0 if {expr} is not a |Float| or a |Number|.
---- Examples: >
+--- Examples: >vim
--- echo trunc(1.456)
---- < 1.0 >
+--- < 1.0 >vim
--- echo trunc(-5.456)
---- < -5.0 >
+--- < -5.0 >vim
--- echo trunc(4.0)
--- < 4.0
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- Compute()->trunc()
+--- <
---
--- @param expr any
--- @return any
@@ -10625,22 +10853,23 @@ function vim.fn.trunc(expr) end
--- Boolean: 6 (|v:true| and |v:false|)
--- Null: 7 (|v:null|)
--- Blob: 10 (|v:t_blob|)
---- For backward compatibility, this method can be used: >
---- :if type(myvar) == type(0)
---- :if type(myvar) == type("")
---- :if type(myvar) == type(function("tr"))
---- :if type(myvar) == type([])
---- :if type(myvar) == type({})
---- :if type(myvar) == type(0.0)
---- :if type(myvar) == type(v:true)
+--- For backward compatibility, this method can be used: >vim
+--- if type(myvar) == type(0) | endif
+--- if type(myvar) == type("") | endif
+--- if type(myvar) == type(function("tr")) | endif
+--- if type(myvar) == type([]) | endif
+--- if type(myvar) == type({}) | endif
+--- if type(myvar) == type(0.0) | endif
+--- if type(myvar) == type(v:true) | endif
--- <In place of checking for |v:null| type it is better to check
---- for |v:null| directly as it is the only value of this type: >
---- :if myvar is v:null
---- < To check if the v:t_ variables exist use this: >
---- :if exists('v:t_number')
+--- for |v:null| directly as it is the only value of this type: >vim
+--- if myvar is v:null | endif
+--- <To check if the v:t_ variables exist use this: >vim
+--- if exists('v:t_number') | endif
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- mylist->type()
+--- <
---
--- @param expr any
--- @return any
@@ -10656,8 +10885,9 @@ function vim.fn.type(expr) end
--- buffer without a file name will not write an undo file.
--- Useful in combination with |:wundo| and |:rundo|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetFilename()->undofile()
+--- <
---
--- @param name string
--- @return string
@@ -10710,14 +10940,14 @@ function vim.fn.undotree() end
--- Remove second and succeeding copies of repeated adjacent
--- {list} items in-place. Returns {list}. If you want a list
---- to remain unmodified make a copy first: >
---- :let newlist = uniq(copy(mylist))
+--- to remain unmodified make a copy first: >vim
+--- let newlist = uniq(copy(mylist))
--- <The default compare function uses the string representation of
--- each item. For the use of {func} and {dict} see |sort()|.
---
--- Returns zero if {list} is not a |List|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mylist->uniq()
--- <
---
@@ -10744,16 +10974,16 @@ function vim.fn.uniq(list, func, dict) end
--- from the UTF-16 index and |charidx()| for getting the
--- character index from the UTF-16 index.
--- Refer to |string-offset-encoding| for more information.
---- Examples: >
---- echo utf16idx('a😊😊', 3) returns 2
---- echo utf16idx('a😊😊', 7) returns 4
---- echo utf16idx('a😊😊', 1, 0, 1) returns 2
---- echo utf16idx('a😊😊', 2, 0, 1) returns 4
---- echo utf16idx('aą́c', 6) returns 2
---- echo utf16idx('aą́c', 6, 1) returns 4
---- echo utf16idx('a😊😊', 9) returns -1
---- <
---- Can also be used as a |method|: >
+--- Examples: >vim
+--- echo utf16idx('a😊😊', 3) " returns 2
+--- echo utf16idx('a😊😊', 7) " returns 4
+--- echo utf16idx('a😊😊', 1, 0, 1) " returns 2
+--- echo utf16idx('a😊😊', 2, 0, 1) " returns 4
+--- echo utf16idx('aą́c', 6) " returns 2
+--- echo utf16idx('aą́c', 6, 1) " returns 4
+--- echo utf16idx('a😊😊', 9) " returns -1
+--- <
+--- Can also be used as a |method|: >vim
--- GetName()->utf16idx(idx)
--- <
---
@@ -10768,8 +10998,9 @@ function vim.fn.utf16idx(string, idx, countcc, charidx) end
--- in arbitrary order. Also see |items()| and |keys()|.
--- Returns zero if {dict} is not a |Dict|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- mydict->values()
+--- <
---
--- @param dict any
--- @return any
@@ -10811,23 +11042,24 @@ function vim.fn.values(dict) end
--- character.
---
--- Note that only marks in the current file can be used.
---- Examples: >
+--- Examples: >vim
--- " With text "foo^Lbar" and cursor on the "^L":
---
---- virtcol(".") " returns 5
---- virtcol(".", 1) " returns [4, 5]
---- virtcol("$") " returns 9
+--- echo virtcol(".") " returns 5
+--- echo virtcol(".", 1) " returns [4, 5]
+--- echo virtcol("$") " returns 9
---
--- " With text " there", with 't at 'h':
---
---- virtcol("'t") " returns 6
---- <The first column is 1. 0 is returned for an error.
---- A more advanced example that echoes the maximum length of
---- all lines: >
+--- echo virtcol("'t") " returns 6
+--- <Techo he first column is 1. 0 is returned for an error.
+--- A echo more advanced example that echoes the maximum length of
+--- all lines: >vim
--- echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetPos()->virtcol()
+--- <
---
--- @param expr any
--- @param list? any
@@ -10850,8 +11082,9 @@ function vim.fn.virtcol(expr, list) end
---
--- See also |screenpos()|, |virtcol()| and |col()|.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->virtcol2col(lnum, col)
+--- <
---
--- @param winid integer
--- @param lnum integer
@@ -10865,8 +11098,8 @@ function vim.fn.virtcol2col(winid, lnum, col) end
--- "V", or "<CTRL-V>" (a single CTRL-V character) for
--- character-wise, line-wise, or block-wise Visual mode
--- respectively.
---- Example: >
---- :exe "normal " .. visualmode()
+--- Example: >vim
+--- exe "normal " .. visualmode()
--- <This enters the same Visual mode as before. It is also useful
--- in scripts if you wish to act differently depending on the
--- Visual mode that was used.
@@ -10906,8 +11139,8 @@ function vim.fn.wait(timeout, condition, interval) end
--- This can be used in mappings to handle the 'wildcharm' option
--- gracefully. (Makes only sense with |mapmode-c| mappings).
---
---- For example to make <c-j> work like <down> in wildmode, use: >
---- :cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
+--- For example to make <c-j> work like <down> in wildmode, use: >vim
+--- cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
--- <
--- (Note, this needs the 'wildcharm' option set appropriately).
---
@@ -10919,7 +11152,7 @@ function vim.fn.wildmenumode() end
--- without triggering autocommands or changing directory. When
--- executing {command} autocommands will be triggered, this may
--- have unexpected side effects. Use `:noautocmd` if needed.
---- Example: >
+--- Example: >vim
--- call win_execute(winid, 'syntax enable')
--- <Doing the same with `setwinvar()` would not trigger
--- autocommands and not actually show syntax highlighting.
@@ -10928,8 +11161,9 @@ function vim.fn.wildmenumode() end
--- an empty string is returned.
---
--- Can also be used as a |method|, the base is passed as the
---- second argument: >
+--- second argument: >vim
--- GetCommand()->win_execute(winid)
+--- <
---
--- @param id any
--- @param command any
@@ -10940,8 +11174,9 @@ function vim.fn.win_execute(id, command, silent) end
--- Returns a |List| with |window-ID|s for windows that contain
--- buffer {bufnr}. When there is none the list is empty.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetBufnr()->win_findbuf()
+--- <
---
--- @param bufnr any
--- @return integer[]
@@ -10955,8 +11190,9 @@ function vim.fn.win_findbuf(bufnr) end
--- number {tab}. The first tab has number one.
--- Return zero if the window cannot be found.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->win_getid()
+--- <
---
--- @param win? any
--- @param tab? any
@@ -10980,7 +11216,7 @@ function vim.fn.win_getid(win, tab) end
---
--- Also see the 'buftype' option.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->win_gettype()
--- <
---
@@ -10992,8 +11228,9 @@ function vim.fn.win_gettype(nr) end
--- tabpage.
--- Return TRUE if successful, FALSE if the window cannot be found.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->win_gotoid()
+--- <
---
--- @param expr any
--- @return 0|1
@@ -11003,8 +11240,9 @@ function vim.fn.win_gotoid(expr) end
--- with ID {expr}: [tabnr, winnr].
--- Return [0, 0] if the window cannot be found.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->win_id2tabwin()
+--- <
---
--- @param expr any
--- @return any
@@ -11013,8 +11251,9 @@ function vim.fn.win_id2tabwin(expr) end
--- Return the window number of window with ID {expr}.
--- Return 0 if the window cannot be found in the current tabpage.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->win_id2win()
+--- <
---
--- @param expr any
--- @return any
@@ -11034,8 +11273,9 @@ function vim.fn.win_id2win(expr) end
--- window, since it has no separator on the right.
--- Only works for the current tab page. *E1308*
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->win_move_separator(offset)
+--- <
---
--- @param nr integer
--- @param offset any
@@ -11053,8 +11293,9 @@ function vim.fn.win_move_separator(nr, offset) end
--- be found and FALSE otherwise.
--- Only works for the current tab page.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinnr()->win_move_statusline(offset)
+--- <
---
--- @param nr integer
--- @param offset any
@@ -11069,7 +11310,7 @@ function vim.fn.win_move_statusline(nr, offset) end
--- Returns [0, 0] if the window cannot be found in the current
--- tabpage.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->win_screenpos()
--- <
---
@@ -11096,7 +11337,7 @@ function vim.fn.win_screenpos(nr) end
--- present, the values of 'splitbelow' and
--- 'splitright' are used.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->win_splitmove(target)
--- <
---
@@ -11112,10 +11353,10 @@ function vim.fn.win_splitmove(nr, target, options) end
--- When {nr} is zero, the number of the buffer in the current
--- window is returned.
--- When window {nr} doesn't exist, -1 is returned.
---- Example: >
---- :echo "The file in the current window is " .. bufname(winbufnr(0))
+--- Example: >vim
+--- echo "The file in the current window is " .. bufname(winbufnr(0))
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- FindWindow()->winbufnr()->bufname()
--- <
---
@@ -11144,10 +11385,10 @@ function vim.fn.windowsversion() end
--- returned. When window {nr} doesn't exist, -1 is returned.
--- An existing window always has a height of zero or more.
--- This excludes any window toolbar line.
---- Examples: >
---- :echo "The current window has " .. winheight(0) .. " lines."
+--- Examples: >vim
+--- echo "The current window has " .. winheight(0) .. " lines."
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetWinid()->winheight()
--- <
---
@@ -11162,29 +11403,35 @@ function vim.fn.winheight(nr) end
--- with number {tabnr}. If the tabpage {tabnr} is not found,
--- returns an empty list.
---
---- For a leaf window, it returns:
+--- For a leaf window, it returns: >
--- ["leaf", {winid}]
+--- <
--- For horizontally split windows, which form a column, it
--- returns: >
--- ["col", [{nested list of windows}]]
--- <For vertically split windows, which form a row, it returns: >
--- ["row", [{nested list of windows}]]
--- <
---- Example: >
+--- Example: >vim
--- " Only one window in the tab page
---- :echo winlayout()
+--- echo winlayout()
+--- < >
--- ['leaf', 1000]
+--- < >vim
--- " Two horizontally split windows
---- :echo winlayout()
+--- echo winlayout()
+--- < >
--- ['col', [['leaf', 1000], ['leaf', 1001]]]
+--- < >vim
--- " The second tab page, with three horizontally split
--- " windows, with two vertically split windows in the
--- " middle window
---- :echo winlayout(2)
+--- echo winlayout(2)
+--- < >
--- ['col', [['leaf', 1002], ['row', [['leaf', 1003],
--- ['leaf', 1001]]], ['leaf', 1000]]]
--- <
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetTabnr()->winlayout()
--- <
---
@@ -11224,12 +11471,12 @@ function vim.fn.winline() end
--- |:wincmd|.
--- When {arg} is invalid an error is given and zero is returned.
--- Also see |tabpagewinnr()| and |win_getid()|.
---- Examples: >
+--- Examples: >vim
--- let window_count = winnr('$')
--- let prev_window = winnr('#')
--- let wnum = winnr('3k')
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetWinval()->winnr()
--- <
---
@@ -11241,10 +11488,10 @@ function vim.fn.winnr(arg) end
--- the current window sizes. Only works properly when no windows
--- are opened or closed and the current window and tab page is
--- unchanged.
---- Example: >
---- :let cmd = winrestcmd()
---- :call MessWithWindowSizes()
---- :exe cmd
+--- Example: >vim
+--- let cmd = winrestcmd()
+--- call MessWithWindowSizes()
+--- exe cmd
--- <
---
--- @return any
@@ -11254,8 +11501,8 @@ function vim.fn.winrestcmd() end
--- the view of the current window.
--- Note: The {dict} does not have to contain all values, that are
--- returned by |winsaveview()|. If values are missing, those
---- settings won't be restored. So you can use: >
---- :call winrestview({'curswant': 4})
+--- settings won't be restored. So you can use: >vim
+--- call winrestview({'curswant': 4})
--- <
--- This will only set the curswant value (the column the cursor
--- wants to move on vertical movements) of the cursor to column 5
@@ -11265,7 +11512,7 @@ function vim.fn.winrestcmd() end
--- If you have changed the values the result is unpredictable.
--- If the window size changed the result won't be the same.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetView()->winrestview()
--- <
---
@@ -11307,16 +11554,17 @@ function vim.fn.winsaveview() end
--- When {nr} is zero, the width of the current window is
--- returned. When window {nr} doesn't exist, -1 is returned.
--- An existing window always has a width of zero or more.
---- Examples: >
---- :echo "The current window has " .. winwidth(0) .. " columns."
---- :if winwidth(0) <= 50
---- : 50 wincmd |
---- :endif
+--- Examples: >vim
+--- echo "The current window has " .. winwidth(0) .. " columns."
+--- if winwidth(0) <= 50
+--- 50 wincmd |
+--- endif
--- <For getting the terminal or screen size, see the 'columns'
--- option.
---
---- Can also be used as a |method|: >
+--- Can also be used as a |method|: >vim
--- GetWinid()->winwidth()
+--- <
---
--- @param nr integer
--- @return any
@@ -11361,13 +11609,13 @@ function vim.fn.wordcount() end
--- last list item. An empty item at the end does cause the
--- last line in the file to end in a NL.
---
---- 'a' Append mode is used, lines are appended to the file: >
---- :call writefile(["foo"], "event.log", "a")
---- :call writefile(["bar"], "event.log", "a")
+--- 'a' Append mode is used, lines are appended to the file: >vim
+--- call writefile(["foo"], "event.log", "a")
+--- call writefile(["bar"], "event.log", "a")
--- <
--- 'D' Delete the file when the current function ends. This
---- works like: >
---- :defer delete({fname})
+--- works like: >vim
+--- defer delete({fname})
--- < Fails when not in a function. Also see |:defer|.
---
--- 's' fsync() is called after writing the file. This flushes
@@ -11386,12 +11634,13 @@ function vim.fn.wordcount() end
--- fails.
---
--- Also see |readfile()|.
---- To copy a file byte for byte: >
---- :let fl = readfile("foo", "b")
---- :call writefile(fl, "foocopy", "b")
+--- To copy a file byte for byte: >vim
+--- let fl = readfile("foo", "b")
+--- call writefile(fl, "foocopy", "b")
---
---- <Can also be used as a |method|: >
+--- <Can also be used as a |method|: >vim
--- GetText()->writefile("thefile")
+--- <
---
--- @param object any
--- @param fname integer
@@ -11402,11 +11651,11 @@ function vim.fn.writefile(object, fname, flags) end
--- Bitwise XOR on the two arguments. The arguments are converted
--- to a number. A List, Dict or Float argument causes an error.
--- Also see `and()` and `or()`.
---- Example: >
---- :let bits = xor(bits, 0x80)
+--- Example: >vim
+--- let bits = xor(bits, 0x80)
--- <
---- Can also be used as a |method|: >
---- :let bits = bits->xor(0x80)
+--- Can also be used as a |method|: >vim
+--- let bits = bits->xor(0x80)
--- <
---
--- @param expr any
diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua
index 7193346758..ee8bbe48a3 100755
--- a/scripts/gen_eval_files.lua
+++ b/scripts/gen_eval_files.lua
@@ -217,14 +217,14 @@ local CONFIG = {
'same way. The difference is that a String is handled like it is one line.',
'When it contains a "\\n" character, this is not seen as a line break for the',
'pattern. It can be matched with a "\\n" in the pattern, or with ".". Example:',
- '>',
- '\t:let a = "aaaa\\nxxxx"',
- '\t:echo matchstr(a, "..\\n..")',
- '\taa',
- '\txx',
- '\t:echo matchstr(a, "a.x")',
- '\ta',
- '\tx',
+ '>vim',
+ '\tlet a = "aaaa\\nxxxx"',
+ '\techo matchstr(a, "..\\n..")',
+ '\t" aa',
+ '\t" xx',
+ '\techo matchstr(a, "a.x")',
+ '\t" a',
+ '\t" x',
'',
'Don\'t forget that "^" will only match at the first character of the String and',
'"$" at the last character of the string. They don\'t match after or before a',
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 266873308c..9acfa0984a 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -41,17 +41,17 @@ M.funcs = {
a |Float| abs() returns a |Float|. When {expr} can be
converted to a |Number| abs() returns a |Number|. Otherwise
abs() gives an error message and returns -1.
- Examples: >
+ Examples: >vim
echo abs(1.456)
- < 1.456 >
+ < 1.456 >vim
echo abs(-5.456)
- < 5.456 >
+ < 5.456 >vim
echo abs(-4)
< 4
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->abs()
-
+ <
]=],
name = 'abs',
params = { { 'expr', 'any' } },
@@ -68,15 +68,15 @@ M.funcs = {
[-1, 1].
Returns NaN if {expr} is outside the range [-1, 1]. Returns
0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo acos(0)
- < 1.570796 >
- :echo acos(-0.5)
+ Examples: >vim
+ echo acos(0)
+ < 1.570796 >vim
+ echo acos(-0.5)
< 2.094395
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->acos()
-
+ <
]=],
float_func = 'acos',
name = 'acos',
@@ -89,18 +89,18 @@ M.funcs = {
base = 1,
desc = [=[
Append the item {expr} to |List| or |Blob| {object}. Returns
- the resulting |List| or |Blob|. Examples: >
- :let alist = add([1, 2, 3], item)
- :call add(mylist, "woodstock")
+ the resulting |List| or |Blob|. Examples: >vim
+ let alist = add([1, 2, 3], item)
+ call add(mylist, "woodstock")
<Note that when {expr} is a |List| it is appended as a single
item. Use |extend()| to concatenate |Lists|.
When {object} is a |Blob| then {expr} must be a number.
Use |insert()| to add an item at another position.
Returns 1 if {object} is not a |List| or a |Blob|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->add(val1)->add(val2)
-
+ <
]=],
name = 'add',
params = { { 'object', 'any' }, { 'expr', 'any' } },
@@ -114,11 +114,11 @@ M.funcs = {
Bitwise AND on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see `or()` and `xor()`.
- Example: >
- :let flag = and(bits, 0x80)
- <Can also be used as a |method|: >
- :let flag = bits->and(0x80)
-
+ Example: >vim
+ let flag = and(bits, 0x80)
+ <Can also be used as a |method|: >vim
+ let flag = bits->and(0x80)
+ <
]=],
name = 'and',
params = { { 'expr', 'any' }, { 'expr', 'any' } },
@@ -129,9 +129,9 @@ M.funcs = {
desc = [=[
Returns Dictionary of |api-metadata|.
- View it in a nice human-readable format: >
- :lua vim.print(vim.fn.api_info())
-
+ View it in a nice human-readable format: >vim
+ lua vim.print(vim.fn.api_info())
+ <
]=],
fast = true,
name = 'api_info',
@@ -151,13 +151,13 @@ M.funcs = {
{lnum} can be zero to insert a line before the first one.
{lnum} is used like with |getline()|.
Returns 1 for failure ({lnum} out of range or out of memory),
- 0 for success. Example: >
- :let failed = append(line('$'), "# THE END")
- :let failed = append(0, ["Chapter 1", "the beginning"])
+ 0 for success. Example: >vim
+ let failed = append(line('$'), "# THE END")
+ let failed = append(0, ["Chapter 1", "the beginning"])
- <Can also be used as a |method| after a List: >
+ <Can also be used as a |method| after a List: >vim
mylist->append(lnum)
-
+ <
]=],
name = 'append',
params = { { 'lnum', 'integer' }, { 'text', 'any' } },
@@ -183,12 +183,12 @@ M.funcs = {
On success 0 is returned, on failure 1 is returned.
If {buf} is not a valid buffer or {lnum} is not valid, an
- error message is given. Example: >
- :let failed = appendbufline(13, 0, "# THE START")
+ error message is given. Example: >vim
+ let failed = appendbufline(13, 0, "# THE START")
<
- Can also be used as a |method| after a List: >
+ Can also be used as a |method| after a List: >vim
mylist->appendbufline(buf, lnum)
-
+ <
]=],
name = 'appendbufline',
params = { { 'buf', 'any' }, { 'lnum', 'integer' }, { 'text', 'string' } },
@@ -245,13 +245,13 @@ M.funcs = {
args = { 0, 2 },
desc = [=[
The result is the {nr}th file in the argument list. See
- |arglist|. "argv(0)" is the first one. Example: >
- :let i = 0
- :while i < argc()
- : let f = escape(fnameescape(argv(i)), '.')
- : exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
- : let i = i + 1
- :endwhile
+ |arglist|. "argv(0)" is the first one. Example: >vim
+ let i = 0
+ while i < argc()
+ let f = escape(fnameescape(argv(i)), '.')
+ exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
+ let i = i + 1
+ endwhile
<Without the {nr} argument, or when {nr} is -1, a |List| with
the whole |arglist| is returned.
@@ -261,7 +261,6 @@ M.funcs = {
Returns an empty string if {nr}th argument is not present in
the argument list. Returns an empty List if the {winid}
argument is invalid.
-
]=],
name = 'argv',
params = { { 'nr', 'integer' }, { 'winid', 'integer' } },
@@ -278,13 +277,13 @@ M.funcs = {
[-1, 1].
Returns NaN if {expr} is outside the range [-1, 1]. Returns
0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo asin(0.8)
- < 0.927295 >
- :echo asin(-0.5)
+ Examples: >vim
+ echo asin(0.8)
+ < 0.927295 >vim
+ echo asin(-0.5)
< -0.523599
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->asin()
<
]=],
@@ -303,7 +302,7 @@ M.funcs = {
Also see |assert_fails()|, |assert_nobeep()| and
|assert-return|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCmd()->assert_beeps()
<
]=],
@@ -326,13 +325,14 @@ M.funcs = {
from the Number 4. And the number 4 is different from the
Float 4.0. The value of 'ignorecase' is not used here, case
always matters.
- Example: >
+ Example: >vim
assert_equal('foo', 'bar')
<Will result in a string to be added to |v:errors|:
test.vim line 12: Expected 'foo' but got 'bar' ~
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->assert_equal([1, 2, 3])
+ <
]=],
name = 'assert_equal',
params = { { 'expected', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } },
@@ -349,8 +349,9 @@ M.funcs = {
When {fname-one} or {fname-two} does not exist the error will
mention that.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLog()->assert_equalfile('expected.log')
+ <
]=],
name = 'assert_equalfile',
params = {},
@@ -364,7 +365,7 @@ M.funcs = {
message is added to |v:errors|. Also see |assert-return|.
This can be used to assert that a command throws an exception.
Using the error number, followed by a colon, avoids problems
- with translations: >
+ with translations: >vim
try
commandthatfails
call assert_false(1, 'command should have failed')
@@ -388,16 +389,16 @@ M.funcs = {
When {error} is a string it must be found literally in the
first reported error. Most often this will be the error code,
- including the colon, e.g. "E123:". >
+ including the colon, e.g. "E123:". >vim
assert_fails('bad cmd', 'E987:')
<
When {error} is a |List| with one or two strings, these are
used as patterns. The first pattern is matched against the
- first reported error: >
+ first reported error: >vim
assert_fails('cmd', ['E987:.*expected bool'])
<The second pattern, if present, is matched against the last
reported error. To only match the last error use an empty
- string for the first error: >
+ string for the first error: >vim
assert_fails('cmd', ['', 'E987:'])
<
If {msg} is empty then it is not used. Do this to get the
@@ -415,9 +416,9 @@ M.funcs = {
Note that beeping is not considered an error, and some failing
commands only beep. Use |assert_beeps()| for those.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCmd()->assert_fails('E99:')
-
+ <
]=],
name = 'assert_fails',
params = {
@@ -443,9 +444,9 @@ M.funcs = {
A value is false when it is zero. When {actual} is not a
number the assert fails.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetResult()->assert_false()
-
+ <
]=],
name = 'assert_false',
params = { { 'actual', 'any' }, { 'msg', 'any' } },
@@ -485,12 +486,12 @@ M.funcs = {
Use "^" and "$" to match with the start and end of the text.
Use both to match the whole text.
- Example: >
+ Example: >vim
assert_match('^f.*o$', 'foobar')
<Will result in a string to be added to |v:errors|:
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
getFile()->assert_match('foo.*')
<
]=],
@@ -507,7 +508,7 @@ M.funcs = {
produces a beep or visual bell.
Also see |assert_beeps()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCmd()->assert_nobeep()
<
]=],
@@ -524,9 +525,8 @@ M.funcs = {
|v:errors| when {expected} and {actual} are equal.
Also see |assert-return|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->assert_notequal([1, 2, 3])
-
<
]=],
name = 'assert_notequal',
@@ -542,7 +542,7 @@ M.funcs = {
|v:errors| when {pattern} matches {actual}.
Also see |assert-return|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
getFile()->assert_notmatch('bar.*')
<
]=],
@@ -558,7 +558,7 @@ M.funcs = {
Report a test failure directly, using String {msg}.
Always returns one.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMessage()->assert_report()
<
]=],
@@ -578,7 +578,7 @@ M.funcs = {
When {actual} is not a number or |v:true| the assert fails.
When {msg} is given it precedes the default message.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetResult()->assert_true()
<
]=],
@@ -595,15 +595,15 @@ M.funcs = {
the range [-pi/2, +pi/2] radians, as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo atan(100)
- < 1.560797 >
- :echo atan(-4.01)
+ Examples: >vim
+ echo atan(100)
+ < 1.560797 >vim
+ echo atan(-4.01)
< -1.326405
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->atan()
-
+ <
]=],
float_func = 'atan',
name = 'atan',
@@ -620,15 +620,15 @@ M.funcs = {
{expr1} and {expr2} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
|Number|.
- Examples: >
- :echo atan2(-1, 1)
- < -0.785398 >
- :echo atan2(1, -1)
+ Examples: >vim
+ echo atan2(-1, 1)
+ < -0.785398 >vim
+ echo atan2(1, -1)
< 2.356194
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->atan2(1)
-
+ <
]=],
name = 'atan2',
params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
@@ -640,13 +640,13 @@ M.funcs = {
base = 1,
desc = [=[
Return a List containing the number value of each byte in Blob
- {blob}. Examples: >
- blob2list(0z0102.0304) returns [1, 2, 3, 4]
- blob2list(0z) returns []
+ {blob}. Examples: >vim
+ blob2list(0z0102.0304) " returns [1, 2, 3, 4]
+ blob2list(0z) " returns []
<Returns an empty List on error. |list2blob()| does the
opposite.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBlob()->blob2list()
<
]=],
@@ -686,7 +686,6 @@ M.funcs = {
{initdir} directory to start browsing in
When the "Cancel" button is hit, something went wrong, or
browsing is not possible, an empty string is returned.
-
]=],
name = 'browsedir',
params = { { 'title', 'any' }, { 'initdir', 'any' } },
@@ -704,14 +703,14 @@ M.funcs = {
created buffer. When {name} is an empty string then a new
buffer is always created.
The buffer will not have 'buflisted' set and not be loaded
- yet. To add some text to the buffer use this: >
+ yet. To add some text to the buffer use this: >vim
let bufnr = bufadd('someName')
call bufload(bufnr)
call setbufline(bufnr, 1, ['some', 'text'])
<Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let bufnr = 'somename'->bufadd()
-
+ <
]=],
name = 'bufadd',
params = { { 'name', 'string' } },
@@ -743,9 +742,9 @@ M.funcs = {
Use "bufexists(0)" to test for the existence of an alternate
file name.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let exists = 'somename'->bufexists()
-
+ <
]=],
name = 'bufexists',
params = { { 'buf', 'any' } },
@@ -799,9 +798,9 @@ M.funcs = {
{buf} exists and is listed (has the 'buflisted' option set).
The {buf} argument is used like with |bufexists()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let listed = 'somename'->buflisted()
-
+ <
]=],
name = 'buflisted',
params = { { 'buf', 'any' } },
@@ -821,9 +820,9 @@ M.funcs = {
there will be no dialog, the buffer will be loaded anyway.
The {buf} argument is used like with |bufexists()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
eval 'somename'->bufload()
-
+ <
]=],
name = 'bufload',
params = { { 'buf', 'any' } },
@@ -838,9 +837,9 @@ M.funcs = {
{buf} exists and is loaded (shown in a window or hidden).
The {buf} argument is used like with |bufexists()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let loaded = 'somename'->bufloaded()
-
+ <
]=],
name = 'bufloaded',
params = { { 'buf', 'any' } },
@@ -871,17 +870,17 @@ M.funcs = {
with a listed buffer, that one is returned. Next unlisted
buffers are searched for.
If the {buf} is a String, but you want to use it as a buffer
- number, force it to be a Number by adding zero to it: >
- :echo bufname("3" + 0)
- <Can also be used as a |method|: >
+ number, force it to be a Number by adding zero to it: >vim
+ echo bufname("3" + 0)
+ <Can also be used as a |method|: >vim
echo bufnr->bufname()
<If the buffer doesn't exist, or doesn't have a name, an empty
- string is returned. >
- bufname("#") alternate buffer name
- bufname(3) name of buffer 3
- bufname("%") name of current buffer
- bufname("file2") name of buffer where "file2" matches.
+ string is returned. >vim
+ echo bufname("#") " alternate buffer name
+ echo bufname(3) " name of buffer 3
+ echo bufname("%") " name of current buffer
+ echo bufname("file2") " name of buffer where "file2" matches.
<
]=],
name = 'bufname',
@@ -899,16 +898,16 @@ M.funcs = {
If the buffer doesn't exist, -1 is returned. Or, if the
{create} argument is present and TRUE, a new, unlisted,
buffer is created and its number is returned.
- bufnr("$") is the last buffer: >
- :let last_buffer = bufnr("$")
+ bufnr("$") is the last buffer: >vim
+ let last_buffer = bufnr("$")
<The result is a Number, which is the highest buffer number
of existing buffers. Note that not all buffers with a smaller
number necessarily exist, because ":bwipeout" may have removed
them. Use bufexists() to test for the existence of a buffer.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
echo bufref->bufnr()
-
+ <
]=],
name = 'bufnr',
params = { { 'buf', 'any' }, { 'create', 'any' } },
@@ -922,16 +921,16 @@ M.funcs = {
The result is a Number, which is the |window-ID| of the first
window associated with buffer {buf}. For the use of {buf},
see |bufname()| above. If buffer {buf} doesn't exist or
- there is no such window, -1 is returned. Example: >
+ there is no such window, -1 is returned. Example: >vim
echo "A window containing buffer 1 is " .. (bufwinid(1))
<
Only deals with the current tab page. See |win_findbuf()| for
finding more.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
FindBuffer()->bufwinid()
-
+ <
]=],
name = 'bufwinid',
params = { { 'buf', 'any' } },
@@ -945,16 +944,16 @@ M.funcs = {
Like |bufwinid()| but return the window number instead of the
|window-ID|.
If buffer {buf} doesn't exist or there is no such window, -1
- is returned. Example: >
+ is returned. Example: >vim
echo "A window containing buffer 1 is " .. (bufwinnr(1))
<The number can be used with |CTRL-W_w| and ":wincmd w"
|:wincmd|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
FindBuffer()->bufwinnr()
-
+ <
]=],
name = 'bufwinnr',
params = { { 'buf', 'any' } },
@@ -974,9 +973,9 @@ M.funcs = {
Returns -1 if the {byte} value is invalid.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetOffset()->byte2line()
-
+ <
]=],
name = 'byte2line',
params = { { 'byte', 'any' } },
@@ -1003,10 +1002,10 @@ M.funcs = {
middle of a character (e.g. in a 4-byte character), then the
byte index of the first byte in the character is returned.
Refer to |string-offset-encoding| for more information.
- Example : >
+ Example : >vim
echo matchstr(str, ".", byteidx(str, 3))
<will display the fourth character. Another way to do the
- same: >
+ same: >vim
let s = strpart(str, byteidx(str, 3))
echo strpart(s, 0, byteidx(s, 1))
<Also see |strgetchar()| and |strcharpart()|.
@@ -1016,14 +1015,14 @@ M.funcs = {
in bytes is returned.
See |charidx()| and |utf16idx()| for getting the character and
UTF-16 index respectively from the byte index.
- Examples: >
- echo byteidx('a😊😊', 2) returns 5
- echo byteidx('a😊😊', 2, 1) returns 1
- echo byteidx('a😊😊', 3, 1) returns 5
+ Examples: >vim
+ echo byteidx('a😊😊', 2) " returns 5
+ echo byteidx('a😊😊', 2, 1) " returns 1
+ echo byteidx('a😊😊', 3, 1) " returns 5
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->byteidx(idx)
-
+ <
]=],
fast = true,
name = 'byteidx',
@@ -1036,7 +1035,7 @@ M.funcs = {
base = 1,
desc = [=[
Like byteidx(), except that a composing character is counted
- as a separate character. Example: >
+ as a separate character. Example: >vim
let s = 'e' .. nr2char(0x301)
echo byteidx(s, 1)
echo byteidxcomp(s, 1)
@@ -1045,9 +1044,9 @@ M.funcs = {
character is 3 bytes), the second echo results in 1 ('e' is
one byte).
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->byteidxcomp(idx)
-
+ <
]=],
fast = true,
name = 'byteidxcomp',
@@ -1067,7 +1066,7 @@ M.funcs = {
{dict} is for functions with the "dict" attribute. It will be
used to set the local variable "self". |Dictionary-function|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFunc()->call([arg, arg], dict)
<
]=],
@@ -1084,17 +1083,17 @@ M.funcs = {
Return the smallest integral value greater than or equal to
{expr} as a |Float| (round up).
{expr} must evaluate to a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo ceil(1.456)
- < 2.0 >
+ < 2.0 >vim
echo ceil(-5.456)
- < -5.0 >
+ < -5.0 >vim
echo ceil(4.0)
< 4.0
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->ceil()
<
]=],
@@ -1148,14 +1147,13 @@ M.funcs = {
{data} may be a string, string convertible, |Blob|, or a list.
If {data} is a list, the items will be joined by newlines; any
newlines in an item will be sent as NUL. To send a final
- newline, include a final empty string. Example: >
- :call chansend(id, ["abc", "123\n456", ""])
+ newline, include a final empty string. Example: >vim
+ call chansend(id, ["abc", "123\n456", ""])
<will send "abc<NL>123<NUL>456<NL>".
chansend() writes raw data, not RPC messages. If the channel
was created with `"rpc":v:true` then the channel expects RPC
messages, use |rpcnotify()| and |rpcrequest()| instead.
-
]=],
name = 'chansend',
params = { { 'id', 'any' }, { 'data', 'any' } },
@@ -1167,12 +1165,12 @@ M.funcs = {
base = 1,
desc = [=[
Return Number value of the first char in {string}.
- Examples: >
- char2nr(" ") returns 32
- char2nr("ABC") returns 65
- char2nr("Γ‘") returns 225
- char2nr("Γ‘"[0]) returns 195
- char2nr("\<M-x>") returns 128
+ Examples: >vim
+ echo char2nr(" ") " returns 32
+ echo char2nr("ABC") " returns 65
+ echo char2nr("Γ‘") " returns 225
+ echo char2nr("Γ‘"[0]) " returns 195
+ echo char2nr("\<M-x>") " returns 128
<Non-ASCII characters are always treated as UTF-8 characters.
{utf8} is ignored, it exists only for backwards-compatibility.
A combining character is a separate character.
@@ -1180,9 +1178,9 @@ M.funcs = {
Returns 0 if {string} is not a |String|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetChar()->char2nr()
-
+ <
]=],
fast = true,
name = 'char2nr',
@@ -1217,11 +1215,11 @@ M.funcs = {
position given with {expr} instead of the byte position.
Example:
- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >
- charcol('.') returns 3
- col('.') returns 7
+ With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >vim
+ echo charcol('.') " returns 3
+ echo col('.') " returns 7
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetPos()->col()
<
]=],
@@ -1260,15 +1258,15 @@ M.funcs = {
from the character index and |utf16idx()| for getting the
UTF-16 index from the character index.
Refer to |string-offset-encoding| for more information.
- Examples: >
- echo charidx('áb́ć', 3) returns 1
- echo charidx('áb́ć', 6, 1) returns 4
- echo charidx('áb́ć', 16) returns -1
- echo charidx('a😊😊', 4, 0, 1) returns 2
+ Examples: >vim
+ echo charidx('áb́ć', 3) " returns 1
+ echo charidx('áb́ć', 6, 1) " returns 4
+ echo charidx('áb́ć', 16) " returns -1
+ echo charidx('a😊😊', 4, 0, 1) " returns 2
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->charidx(idx)
-
+ <
]=],
name = 'charidx',
params = {
@@ -1298,14 +1296,14 @@ M.funcs = {
this to another chdir() to restore the directory.
On failure, returns an empty string.
- Example: >
+ Example: >vim
let save_dir = chdir(newdir)
if save_dir != ""
" ... do some work
call chdir(save_dir)
endif
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetDir()->chdir()
<
]=],
@@ -1325,8 +1323,9 @@ M.funcs = {
When {lnum} is invalid -1 is returned.
See |C-indenting|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->cindent()
+ <
]=],
name = 'cindent',
params = { { 'lnum', 'integer' } },
@@ -1342,7 +1341,7 @@ M.funcs = {
If {win} is specified, use the window with this number or
window ID instead of the current window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWin()->clearmatches()
<
]=],
@@ -1377,11 +1376,11 @@ M.funcs = {
For the screen column position use |virtcol()|. For the
character position use |charcol()|.
Note that only marks in the current file can be used.
- Examples: >
- col(".") column of cursor
- col("$") length of cursor line plus one
- col("'t") column of mark t
- col("'" .. markname) column of mark markname
+ Examples: >vim
+ echo col(".") " column of cursor
+ echo col("$") " length of cursor line plus one
+ echo col("'t") " column of mark t
+ echo col("'" .. markname) " column of mark markname
<The first column is 1. Returns 0 if {expr} is invalid or when
the window with ID {winid} is not found.
For an uppercase mark the column may actually be in another
@@ -1389,13 +1388,12 @@ M.funcs = {
For the cursor position, when 'virtualedit' is active, the
column is one higher if the cursor is after the end of the
line. Also, when using a <Cmd> mapping the cursor isn't
- moved, this can be used to obtain the column in Insert mode: >
- :imap <F2> <Cmd>echo col(".").."\n"<CR>
+ moved, this can be used to obtain the column in Insert mode: >vim
+ imap <F2> <Cmd>echo col(".").."\n"<CR>
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetPos()->col()
<
-
]=],
name = 'col',
params = { { 'expr', 'any' }, { 'winid', 'integer' } },
@@ -1423,7 +1421,7 @@ M.funcs = {
The match can be selected with CTRL-N and CTRL-P as usual with
Insert mode completion. The popup menu will appear if
specified, see |ins-completion-menu|.
- Example: >
+ Example: >vim
inoremap <F5> <C-R>=ListMonths()<CR>
func ListMonths()
@@ -1436,9 +1434,9 @@ M.funcs = {
an empty string is returned to avoid a zero being inserted.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetMatches()->complete(col('.'))
-
+ <
]=],
name = 'complete',
params = { { 'startcol', 'any' }, { 'matches', 'any' } },
@@ -1458,9 +1456,9 @@ M.funcs = {
See |complete-functions| for an explanation of {expr}. It is
the same as one item in the list that 'omnifunc' would return.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMoreMatches()->complete_add()
-
+ <
]=],
name = 'complete_add',
params = { { 'expr', 'any' } },
@@ -1534,7 +1532,7 @@ M.funcs = {
Returns an empty |Dictionary| on error.
- Examples: >
+ Examples: >vim
" Get all items
call complete_info()
" Get only 'mode'
@@ -1542,7 +1540,7 @@ M.funcs = {
" Get only 'mode' and 'pum_visible'
call complete_info(['mode', 'pum_visible'])
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetItems()->complete_info()
<
]=],
@@ -1566,11 +1564,11 @@ M.funcs = {
some systems the string is wrapped when it doesn't fit.
{choices} is a String, with the individual choices separated
- by '\n', e.g. >
+ by '\n', e.g. >vim
confirm("Save changes?", "&Yes\n&No\n&Cancel")
<The letter after the '&' is the shortcut key for that choice.
Thus you can type 'c' to select "Cancel". The shortcut does
- not need to be the first letter: >
+ not need to be the first letter: >vim
confirm("file has been modified", "&Save\nSave &All")
<For the console, the first letter of each choice is used as
the default shortcut key. Case is ignored.
@@ -1589,7 +1587,7 @@ M.funcs = {
If the user aborts the dialog by pressing <Esc>, CTRL-C,
or another valid interrupt key, confirm() returns 0.
- An example: >
+ An example: >vim
let choice = confirm("What do you want?",
\ "&Apples\n&Oranges\n&Bananas", 2)
if choice == 0
@@ -1606,7 +1604,7 @@ M.funcs = {
don't fit, a vertical layout is used anyway. For some systems
the horizontal layout is always used.
- Can also be used as a |method|in: >
+ Can also be used as a |method|in: >vim
BuildMessage()->confirm("&Yes\n&No")
<
]=],
@@ -1627,8 +1625,9 @@ M.funcs = {
changing an item changes the contents of both |Lists|.
A |Dictionary| is copied in a similar way as a |List|.
Also see |deepcopy()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->copy()
+ <
]=],
name = 'copy',
params = { { 'expr', 'any' } },
@@ -1642,14 +1641,15 @@ M.funcs = {
Return the cosine of {expr}, measured in radians, as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo cos(100)
- < 0.862319 >
- :echo cos(-4.01)
+ Examples: >vim
+ echo cos(100)
+ < 0.862319 >vim
+ echo cos(-4.01)
< -0.646043
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->cos()
+ <
]=],
float_func = 'cos',
name = 'cos',
@@ -1665,15 +1665,15 @@ M.funcs = {
[1, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo cosh(0.5)
- < 1.127626 >
- :echo cosh(-0.5)
+ Examples: >vim
+ echo cosh(0.5)
+ < 1.127626 >vim
+ echo cosh(-0.5)
< -1.127626
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->cosh()
-
+ <
]=],
float_func = 'cosh',
name = 'cosh',
@@ -1697,7 +1697,7 @@ M.funcs = {
occurrences of {expr} is returned. Zero is returned when
{expr} is an empty string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->count(val)
<
]=],
@@ -1735,7 +1735,6 @@ M.funcs = {
If {types} is given and is a |List| of |String|s, it specifies
which |context-types| to include in the pushed context.
Otherwise, all context types are included.
-
]=],
name = 'ctxpush',
params = { { 'types', 'any' } },
@@ -1748,7 +1747,6 @@ M.funcs = {
|context-stack| to that represented by {context}.
{context} is a Dictionary with context data (|context-dict|).
If {index} is not given, it is assumed to be 0 (i.e.: top).
-
]=],
name = 'ctxset',
params = { { 'context', 'any' }, { 'index', 'any' } },
@@ -1757,7 +1755,6 @@ M.funcs = {
ctxsize = {
desc = [=[
Returns the size of the |context-stack|.
-
]=],
name = 'ctxsize',
params = {},
@@ -1805,9 +1802,9 @@ M.funcs = {
position within a <Tab> or after the last character.
Returns 0 when the position could be set, -1 otherwise.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCursorPos()->cursor()
-
+ <
]=],
name = 'cursor',
params = { { 'list', 'any' } },
@@ -1825,7 +1822,7 @@ M.funcs = {
Returns |TRUE| if successfully interrupted the program.
Otherwise returns |FALSE|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPid()->debugbreak()
<
]=],
@@ -1857,9 +1854,9 @@ M.funcs = {
{noref} set to 1 will fail.
Also see |copy()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetObject()->deepcopy()
-
+ <
]=],
name = 'deepcopy',
params = { { 'expr', 'any' }, { 'noref', 'any' } },
@@ -1887,9 +1884,9 @@ M.funcs = {
operation was successful and -1/true when the deletion failed
or partly failed.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->delete()
-
+ <
]=],
name = 'delete',
params = { { 'fname', 'integer' }, { 'flags', 'string' } },
@@ -1913,7 +1910,7 @@ M.funcs = {
when using |line()| this refers to the current buffer. Use "$"
to refer to the last line in buffer {buf}.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->deletebufline(1)
<
]=],
@@ -1934,7 +1931,7 @@ M.funcs = {
After this is called, every change on {dict} and on keys
matching {pattern} will result in {callback} being invoked.
- For example, to watch all global variables: >
+ For example, to watch all global variables: >vim
silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
function! OnDictChanged(d,k,z)
echomsg string(a:k) string(a:z)
@@ -1962,7 +1959,6 @@ M.funcs = {
This function can be used by plugins to implement options with
validation and parsing logic.
-
]=],
name = 'dictwatcheradd',
params = { { 'dict', 'any' }, { 'pattern', 'any' }, { 'callback', 'any' } },
@@ -1991,7 +1987,6 @@ M.funcs = {
current buffer. This allows an autocommand that starts
editing another buffer to set 'filetype' and load a syntax
file.
-
]=],
fast = true,
name = 'did_filetype',
@@ -2010,9 +2005,9 @@ M.funcs = {
line, "'m" mark m, etc.
Returns 0 if the current window is not in diff mode.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->diff_filler()
-
+ <
]=],
name = 'diff_filler',
params = { { 'lnum', 'integer' } },
@@ -2032,10 +2027,9 @@ M.funcs = {
The highlight ID can be used with |synIDattr()| to obtain
syntax information about the highlighting.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->diff_hlID(col)
<
-
]=],
name = 'diff_hlID',
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },
@@ -2053,18 +2047,17 @@ M.funcs = {
Also see |digraph_getlist()|.
- Examples: >
+ Examples: >vim
" Get a built-in digraph
- :echo digraph_get('00') " Returns '∞'
+ echo digraph_get('00') " Returns '∞'
" Get a user-defined digraph
- :call digraph_set('aa', 'あ')
- :echo digraph_get('aa') " Returns 'あ'
+ call digraph_set('aa', 'あ')
+ echo digraph_get('aa') " Returns 'あ'
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetChars()->digraph_get()
<
-
]=],
name = 'digraph_get',
params = { { 'chars', 'any' } },
@@ -2080,17 +2073,16 @@ M.funcs = {
Also see |digraph_get()|.
- Examples: >
+ Examples: >vim
" Get user-defined digraphs
- :echo digraph_getlist()
+ echo digraph_getlist()
" Get all the digraphs, including default digraphs
- :echo digraph_getlist(1)
+ echo digraph_getlist(1)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetNumber()->digraph_getlist()
<
-
]=],
name = 'digraph_getlist',
params = { { 'listall', 'any' } },
@@ -2113,13 +2105,12 @@ M.funcs = {
If you want to define multiple digraphs at once, you can use
|digraph_setlist()|.
- Example: >
+ Example: >vim
call digraph_set(' ', 'あ')
<
- Can be used as a |method|: >
+ Can be used as a |method|: >vim
GetString()->digraph_set('あ')
<
-
]=],
name = 'digraph_set',
params = { { 'chars', 'any' }, { 'digraph', 'any' } },
@@ -2133,20 +2124,19 @@ M.funcs = {
digraphs at once. {digraphlist} is a list composed of lists,
where each list contains two strings with {chars} and
{digraph} as in |digraph_set()|. *E1216*
- Example: >
+ Example: >vim
call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
<
- It is similar to the following: >
+ It is similar to the following: >vim
for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
call digraph_set(chars, digraph)
endfor
<Except that the function returns after the first error,
following digraphs will not be added.
- Can be used as a |method|: >
+ Can be used as a |method|: >vim
GetList()->digraph_setlist()
<
-
]=],
name = 'digraph_setlist',
params = { { 'digraphlist', 'any' } },
@@ -2164,9 +2154,9 @@ M.funcs = {
- |v:false| and |v:null| are empty, |v:true| is not.
- A |Blob| is empty when its length is zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->empty()
-
+ <
]=],
name = 'empty',
params = { { 'expr', 'any' } },
@@ -2175,12 +2165,12 @@ M.funcs = {
environ = {
desc = [=[
Return all of environment variables as dictionary. You can
- check if an environment variable exists like this: >
- :echo has_key(environ(), 'HOME')
+ check if an environment variable exists like this: >vim
+ echo has_key(environ(), 'HOME')
<Note that the variable name may be CamelCase; to ignore case
- use this: >
- :echo index(keys(environ()), 'HOME', 0, 1) != -1
-
+ use this: >vim
+ echo index(keys(environ()), 'HOME', 0, 1) != -1
+ <
]=],
fast = true,
name = 'environ',
@@ -2192,13 +2182,13 @@ M.funcs = {
base = 1,
desc = [=[
Escape the characters in {chars} that occur in {string} with a
- backslash. Example: >
- :echo escape('c:\program files\vim', ' \')
+ backslash. Example: >vim
+ echo escape('c:\program files\vim', ' \')
<results in: >
c:\\program\ files\\vim
<Also see |shellescape()| and |fnameescape()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->escape(' \')
<
]=],
@@ -2217,9 +2207,9 @@ M.funcs = {
of them. Also works for |Funcref|s that refer to existing
functions.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
argv->join()->eval()
-
+ <
]=],
name = 'eval',
params = { { 'string', 'string' } },
@@ -2231,7 +2221,6 @@ M.funcs = {
interrupted while waiting for the user to type a character,
e.g., when dropping a file on Vim. This means interactive
commands cannot be used. Otherwise zero is returned.
-
]=],
name = 'eventhandler',
params = {},
@@ -2263,9 +2252,9 @@ M.funcs = {
-1 not implemented on this system
|exepath()| can be used to get the full path of an executable.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->executable()
-
+ <
]=],
fast = true,
name = 'executable',
@@ -2280,9 +2269,9 @@ M.funcs = {
If {command} is a |String|, returns {command} output.
If {command} is a |List|, returns concatenated outputs.
Line continuations in {command} are not recognized.
- Examples: >
+ Examples: >vim
echo execute('echon "foo"')
- < foo >
+ < foo >vim
echo execute(['echon "foo"', 'echon "bar"'])
< foobar
@@ -2293,7 +2282,7 @@ M.funcs = {
The default is "silent". Note that with "silent!", unlike
`:redir`, error messages are dropped.
- To get a list of lines use `split()` on the result: >
+ To get a list of lines use `split()` on the result: >vim
execute('args')->split("\n")
<This function is not available in the |sandbox|.
@@ -2303,9 +2292,9 @@ M.funcs = {
To execute a command in another window than the current one
use `win_execute()`.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->execute()
-
+ <
]=],
name = 'execute',
params = { { 'command', 'any' }, { 'silent', 'boolean' } },
@@ -2320,7 +2309,7 @@ M.funcs = {
Returns empty string otherwise.
If {expr} starts with "./" the |current-directory| is used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->exepath()
<
]=],
@@ -2345,11 +2334,11 @@ M.funcs = {
entries, |List| items, etc.
Beware that evaluating an index may
cause an error message for an invalid
- expression. E.g.: >
- :let l = [1, 2, 3]
- :echo exists("l[5]")
- < 0 >
- :echo exists("l[xx]")
+ 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,
@@ -2389,39 +2378,39 @@ M.funcs = {
##event autocommand for this event is
supported.
- Examples: >
- exists("&mouse")
- exists("$HOSTNAME")
- exists("*strftime")
- exists("*s:MyFunc")
- exists("*MyFunc")
- exists("bufcount")
- exists(":Make")
- exists("#CursorHold")
- exists("#BufReadPre#*.gz")
- exists("#filetypeindent")
- exists("#filetypeindent#FileType")
- exists("#filetypeindent#FileType#*")
- exists("##ColorScheme")
+ Examples: >vim
+ echo exists("&mouse")
+ echo exists("$HOSTNAME")
+ echo exists("*strftime")
+ echo exists("*s:MyFunc")
+ echo exists("*MyFunc")
+ 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: >
- exists(":make")
- <NOT working example: >
- exists(":make install")
+ 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: >
- exists(bufcount)
+ 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.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Varname()->exists()
-
+ <
]=],
name = 'exists',
params = { { 'expr', 'any' } },
@@ -2436,15 +2425,15 @@ M.funcs = {
[0, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo exp(2)
- < 7.389056 >
- :echo exp(-1)
+ Examples: >vim
+ echo exp(2)
+ < 7.389056 >vim
+ echo exp(-1)
< 0.367879
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->exp()
-
+ <
]=],
float_func = 'exp',
name = 'exp',
@@ -2499,18 +2488,18 @@ M.funcs = {
:r root (one extension removed)
:e extension only
- Example: >
- :let &tags = expand("%:p:h") .. "/tags"
+ Example: >vim
+ let &tags = expand("%:p:h") .. "/tags"
<Note that when expanding a string that starts with '%', '#' or
- '<', any following text is ignored. This does NOT work: >
- :let doesntwork = expand("%:h.bak")
- <Use this: >
- :let doeswork = expand("%:h") .. ".bak"
+ '<', any following text is ignored. This does NOT work: >vim
+ let doesntwork = expand("%:h.bak")
+ <Use this: >vim
+ let doeswork = expand("%:h") .. ".bak"
<Also note that expanding "<cfile>" and others only returns the
referenced file name without further expansion. If "<cfile>"
is "~/.cshrc", you need to do another expand() to have the
- "~/" expanded into the path of the home directory: >
- :echo expand(expand("<cfile>"))
+ "~/" expanded into the path of the home directory: >vim
+ echo expand(expand("<cfile>"))
<
There cannot be white space between the variables and the
following modifier. The |fnamemodify()| function can be used
@@ -2530,8 +2519,8 @@ M.funcs = {
{nosuf} argument is given and it is |TRUE|.
Names for non-existing files are included. The "**" item can
be used to search in a directory tree. For example, to find
- all "README" files in the current directory and below: >
- :echo expand("**/README")
+ all "README" files in the current directory and below: >vim
+ echo expand("**/README")
<
expand() can also be used to expand variables and environment
variables that are only known in a shell. But this can be
@@ -2545,9 +2534,9 @@ M.funcs = {
See |glob()| for finding existing files. See |system()| for
getting the raw output of an external command.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Getpattern()->expand()
-
+ <
]=],
name = 'expand',
params = { { 'string', 'string' }, { 'nosuf', 'boolean' }, { 'list', 'any' } },
@@ -2573,12 +2562,14 @@ M.funcs = {
Returns the expanded string. If an error is encountered
during expansion, the unmodified {string} is returned.
- Example: >
- :echo expandcmd('make %<.o')
+ Example: >vim
+ echo expandcmd('make %<.o')
+ < >
make /path/runtime/doc/builtin.o
- :echo expandcmd('make %<.o', {'errmsg': v:true})
+ < >vim
+ echo expandcmd('make %<.o', {'errmsg': v:true})
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->expandcmd()
<
]=],
@@ -2598,16 +2589,16 @@ M.funcs = {
item with index {expr3} in {expr1}. When {expr3} is zero
insert before the first item. When {expr3} is equal to
len({expr1}) then {expr2} is appended.
- Examples: >
- :echo sort(extend(mylist, [7, 5]))
- :call extend(mylist, [2, 3], 1)
+ Examples: >vim
+ echo sort(extend(mylist, [7, 5]))
+ call extend(mylist, [2, 3], 1)
<When {expr1} is the same List as {expr2} then the number of
items copied is equal to the original length of the List.
E.g., when {expr3} is 1 you get N new copies of the first item
(where N is the original length of the List).
Use |add()| to concatenate one item to a list. To concatenate
- two lists into a new list use the + operator: >
- :let newlist = [1, 2, 3] + [4, 5]
+ two lists into a new list use the + operator: >vim
+ let newlist = [1, 2, 3] + [4, 5]
<
If they are |Dictionaries|:
Add all entries from {expr2} to {expr1}.
@@ -2625,7 +2616,7 @@ M.funcs = {
fails.
Returns {expr1}. Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->extend(otherlist)
<
]=],
@@ -2693,9 +2684,9 @@ M.funcs = {
Return value is always 0.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetInput()->feedkeys()
-
+ <
]=],
name = 'feedkeys',
params = { { 'string', 'string' }, { 'mode', 'string' } },
@@ -2723,15 +2714,19 @@ M.funcs = {
expression, which is used as a String.
If you don't care about the file being readable you can use
|glob()|.
- {file} is used as-is, you may want to expand wildcards first: >
+ {file} is used as-is, you may want to expand wildcards first: >vim
echo filereadable('~/.vimrc')
+ < >
0
+ < >vim
echo filereadable(expand('~/.vimrc'))
+ < >
1
+ <
- <Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->filereadable()
-
+ <
]=],
fast = true,
name = 'filereadable',
@@ -2748,9 +2743,9 @@ M.funcs = {
exist, or is not writable, the result is 0. If {file} is a
directory, and we can write to it, the result is 2.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->filewritable()
-
+ <
]=],
fast = true,
name = 'filewritable',
@@ -2775,11 +2770,11 @@ M.funcs = {
the current item. For a |Blob| |v:key| has the index of the
current byte.
- Examples: >
+ Examples: >vim
call filter(mylist, 'v:val !~ "OLD"')
- <Removes the items where "OLD" appears. >
+ <Removes the items where "OLD" appears. >vim
call filter(mydict, 'v:key >= 8')
- <Removes the items with a key below 8. >
+ <Removes the items with a key below 8. >vim
call filter(var, 0)
<Removes all the items, thus clears the |List| or |Dictionary|.
@@ -2791,19 +2786,19 @@ M.funcs = {
1. the key or the index of the current item.
2. the value of the current item.
The function must return |TRUE| if the item should be kept.
- Example that keeps the odd items of a list: >
+ Example that keeps the odd items of a list: >vim
func Odd(idx, val)
return a:idx % 2 == 1
endfunc
call filter(mylist, function('Odd'))
- <It is shorter when using a |lambda|: >
+ <It is shorter when using a |lambda|: >vim
call filter(myList, {idx, val -> idx * val <= 42})
- <If you do not use "val" you can leave it out: >
+ <If you do not use "val" you can leave it out: >vim
call filter(myList, {idx -> idx % 2 == 1})
<
The operation is done in-place. If you want a |List| or
- |Dictionary| to remain unmodified make a copy first: >
- :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
+ |Dictionary| to remain unmodified make a copy first: >vim
+ let l = filter(copy(mylist), 'v:val =~ "KEEP"')
<Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
filtered. When an error is encountered while evaluating
@@ -2811,9 +2806,9 @@ M.funcs = {
{expr2} is a Funcref errors inside a function are ignored,
unless it was defined with the "abort" flag.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->filter(expr2)
-
+ <
]=],
name = 'filter',
params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
@@ -2840,9 +2835,9 @@ M.funcs = {
This is quite similar to the ex-command `:find`.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->finddir()
-
+ <
]=],
name = 'finddir',
params = { { 'name', 'string' }, { 'path', 'string' }, { 'count', 'any' } },
@@ -2854,14 +2849,14 @@ M.funcs = {
desc = [=[
Just like |finddir()|, but find a file instead of a directory.
Uses 'suffixesadd'.
- Example: >
- :echo findfile("tags.vim", ".;")
+ Example: >vim
+ echo findfile("tags.vim", ".;")
<Searches from the directory of the current file upwards until
it finds the file "tags.vim".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->findfile()
-
+ <
]=],
name = 'findfile',
params = { { 'name', 'string' }, { 'path', 'string' }, { 'count', 'any' } },
@@ -2883,13 +2878,13 @@ M.funcs = {
If there is an error the number zero is returned.
- Example: >
- :echo flatten([1, [2, [3, 4]], 5])
- < [1, 2, 3, 4, 5] >
- :echo flatten([1, [2, [3, 4]], 5], 1)
+ Example: >vim
+ echo flatten([1, [2, [3, 4]], 5])
+ < [1, 2, 3, 4, 5] >vim
+ echo flatten([1, [2, [3, 4]], 5], 1)
< [1, 2, [3, 4], 5]
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->flatten()
<
]=],
@@ -2922,21 +2917,21 @@ M.funcs = {
64-bit Number support is enabled, 0x7fffffffffffffff or
-0x7fffffffffffffff). NaN results in -0x80000000 (or when
64-bit Number support is enabled, -0x8000000000000000).
- Examples: >
+ Examples: >vim
echo float2nr(3.95)
- < 3 >
+ < 3 >vim
echo float2nr(-23.45)
- < -23 >
+ < -23 >vim
echo float2nr(1.0e100)
- < 2147483647 (or 9223372036854775807) >
+ < 2147483647 (or 9223372036854775807) >vim
echo float2nr(-1.0e150)
- < -2147483647 (or -9223372036854775807) >
+ < -2147483647 (or -9223372036854775807) >vim
echo float2nr(1.0e-100)
< 0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->float2nr()
-
+ <
]=],
name = 'float2nr',
params = { { 'expr', 'any' } },
@@ -2950,17 +2945,17 @@ M.funcs = {
{expr} as a |Float| (round down).
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo floor(1.856)
- < 1.0 >
+ < 1.0 >vim
echo floor(-5.456)
- < -6.0 >
+ < -6.0 >vim
echo floor(4.0)
< 4.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->floor()
-
+ <
]=],
float_func = 'floor',
name = 'floor',
@@ -2980,15 +2975,15 @@ M.funcs = {
{expr1} and {expr2} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
|Number|.
- Examples: >
- :echo fmod(12.33, 1.22)
- < 0.13 >
- :echo fmod(-12.33, 1.22)
+ Examples: >vim
+ echo fmod(12.33, 1.22)
+ < 0.13 >vim
+ echo fmod(-12.33, 1.22)
< -0.13
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->fmod(1.22)
-
+ <
]=],
name = 'fmod',
params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
@@ -2999,7 +2994,7 @@ M.funcs = {
base = 1,
desc = [=[
Escape {string} for use as file name command argument. All
- characters that have a special meaning, such as '%' and '|'
+ characters that have a special meaning, such as `'%'` and `'|'`
are escaped with a backslash.
For most systems the characters escaped are
" \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
@@ -3007,15 +3002,15 @@ M.funcs = {
A leading '+' and '>' is also escaped (special after |:edit|
and |:write|). And a "-" by itself (special after |:cd|).
Returns an empty string on error.
- Example: >
- :let fname = '+some str%nge|name'
- :exe "edit " .. fnameescape(fname)
- <results in executing: >
+ Example: >vim
+ let fname = '+some str%nge|name'
+ exe "edit " .. fnameescape(fname)
+ <results in executing: >vim
edit \+some\ str\%nge\|name
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->fnameescape()
-
+ <
]=],
fast = true,
name = 'fnameescape',
@@ -3030,8 +3025,8 @@ M.funcs = {
Modify file name {fname} according to {mods}. {mods} is a
string of characters like it is used for file names on the
command line. See |filename-modifiers|.
- Example: >
- :echo fnamemodify("main.c", ":p:h")
+ Example: >vim
+ echo fnamemodify("main.c", ":p:h")
<results in: >
/home/user/vim/vim/src
<If {mods} is empty or an unsupported modifier is used then
@@ -3043,9 +3038,9 @@ M.funcs = {
Note: Environment variables don't work in {fname}, use
|expand()| first then.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->fnamemodify(':p:h')
-
+ <
]=],
fast = true,
name = 'fnamemodify',
@@ -3063,9 +3058,9 @@ M.funcs = {
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldclosed()
-
+ <
]=],
name = 'foldclosed',
params = { { 'lnum', 'integer' } },
@@ -3082,9 +3077,9 @@ M.funcs = {
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldclosedend()
-
+ <
]=],
name = 'foldclosedend',
params = { { 'lnum', 'integer' } },
@@ -3106,7 +3101,7 @@ M.funcs = {
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldlevel()
<
]=],
@@ -3132,7 +3127,6 @@ M.funcs = {
will be filled with the fold char from the 'fillchars'
setting.
Returns an empty string when there is no fold.
-
]=],
name = 'foldtext',
params = {},
@@ -3151,7 +3145,7 @@ M.funcs = {
line, "'m" mark m, etc.
Useful when exporting folded text, e.g., to HTML.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->foldtextresult()
<
]=],
@@ -3178,7 +3172,7 @@ M.funcs = {
For example `fullcommand('s')`, `fullcommand('sub')`,
`fullcommand(':%substitute')` all return "substitute".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->fullcommand()
<
]=],
@@ -3202,7 +3196,7 @@ M.funcs = {
instead). {name} cannot be a builtin function.
Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFuncname()->funcref([arg])
<
]=],
@@ -3220,7 +3214,7 @@ M.funcs = {
{name} can also be a Funcref or a partial. When it is a
partial the dict stored in it will be used and the {dict}
- argument is not allowed. E.g.: >
+ argument is not allowed. E.g.: >vim
let FuncWithArg = function(dict.Func, [arg])
let Broken = function(dict.Func, [arg], dict)
<
@@ -3233,38 +3227,41 @@ M.funcs = {
the Funcref and will be used when the Funcref is called.
The arguments are passed to the function in front of other
- arguments, but after any argument from |method|. Example: >
+ arguments, but after any argument from |method|. Example: >vim
func Callback(arg1, arg2, name)
"...
+ endfunc
let Partial = function('Callback', ['one', 'two'])
"...
call Partial('name')
- <Invokes the function as with: >
+ <Invokes the function as with: >vim
call Callback('one', 'two', 'name')
- <With a |method|: >
+ <With a |method|: >vim
func Callback(one, two, three)
"...
+ endfunc
let Partial = function('Callback', ['two'])
"...
eval 'one'->Partial('three')
- <Invokes the function as with: >
+ <Invokes the function as with: >vim
call Callback('one', 'two', 'three')
<The function() call can be nested to add more arguments to the
Funcref. The extra arguments are appended to the list of
- arguments. Example: >
+ arguments. Example: >vim
func Callback(arg1, arg2, name)
"...
+ endfunc
let Func = function('Callback', ['one'])
let Func2 = function(Func, ['two'])
"...
call Func2('name')
- <Invokes the function as with: >
+ <Invokes the function as with: >vim
call Callback('one', 'two', 'name')
<The Dictionary is only useful when calling a "dict" function.
- In that case the {dict} is passed in as "self". Example: >
+ In that case the {dict} is passed in as "self". Example: >vim
function Callback() dict
echo "called for " .. self.name
endfunction
@@ -3275,25 +3272,26 @@ M.funcs = {
call Func() " will echo: called for example
<The use of function() is not needed when there are no extra
arguments, these two are equivalent, if Callback() is defined
- as context.Callback(): >
+ as context.Callback(): >vim
let Func = function('Callback', context)
let Func = context.Callback
- <The argument list and the Dictionary can be combined: >
+ <The argument list and the Dictionary can be combined: >vim
function Callback(arg1, count) dict
"...
+ endfunction
let context = {"name": "example"}
let Func = function('Callback', ['one'], context)
"...
call Func(500)
- <Invokes the function as with: >
+ <Invokes the function as with: >vim
call context.Callback('one', 500)
<
Returns 0 on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFuncname()->function([arg])
-
+ <
]=],
name = 'function',
params = { { 'name', 'string' }, { 'arglist', 'any' }, { 'dict', 'any' } },
@@ -3321,7 +3319,6 @@ M.funcs = {
The garbage collection is not done immediately but only when
it's safe to perform. This is when waiting for the user to
type a character.
-
]=],
name = 'garbagecollect',
params = { { 'atexit', 'any' } },
@@ -3334,8 +3331,9 @@ M.funcs = {
Get item {idx} from |List| {list}. When this item is not
available return {default}. Return zero when {default} is
omitted.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->get(idx)
+ <
]=],
name = 'get',
params = { { 'list', 'any[]' }, { 'idx', 'integer' }, { 'default', 'any' } },
@@ -3359,7 +3357,7 @@ M.funcs = {
desc = [=[
Get item with key {key} from |Dictionary| {dict}. When this
item is not available return {default}. Return zero when
- {default} is omitted. Useful example: >
+ {default} is omitted. Useful example: >vim
let val = get(g:, 'var_name', 'default')
<This gets the value of g:var_name if it exists, and uses
"default" when it does not exist.
@@ -3429,8 +3427,8 @@ M.funcs = {
displayed in the window in the past.
If you want the line number of the
last known cursor position in a given
- window, use |line()|: >
- :echo line('.', {winid})
+ window, use |line()|: >vim
+ echo line('.', {winid})
<
linecount Number of lines in the buffer (only
valid when loaded)
@@ -3447,20 +3445,20 @@ M.funcs = {
windows List of |window-ID|s that display this
buffer
- Examples: >
+ Examples: >vim
for buf in getbufinfo()
echo buf.name
endfor
for buf in getbufinfo({'buflisted':1})
if buf.changed
- ....
+ " ....
endif
endfor
<
- To get buffer-local options use: >
+ To get buffer-local options use: >vim
getbufvar({bufnr}, '&option_name')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->getbufinfo()
<
]=],
@@ -3493,10 +3491,10 @@ M.funcs = {
This function works only for loaded buffers. For unloaded and
non-existing buffers, an empty |List| is returned.
- Example: >
- :let lines = getbufline(bufnr("myfile"), 1, "$")
+ Example: >vim
+ let lines = getbufline(bufnr("myfile"), 1, "$")
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetBufnr()->getbufline(lnum)
<
]=],
@@ -3535,11 +3533,11 @@ M.funcs = {
For the use of {buf}, see |bufname()| above.
When the buffer or variable doesn't exist {def} or an empty
string is returned, there is no error message.
- Examples: >
- :let bufmodified = getbufvar(1, "&mod")
- :echo "todo myvar = " .. getbufvar("todo", "myvar")
+ Examples: >vim
+ let bufmodified = getbufvar(1, "&mod")
+ echo "todo myvar = " .. getbufvar("todo", "myvar")
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetBufnr()->getbufvar(varname)
<
]=],
@@ -3577,9 +3575,9 @@ M.funcs = {
position refers to the position in the list. For other
buffers, it is set to the length of the list.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->getchangelist()
-
+ <
]=],
name = 'getchangelist',
params = { { 'buf', 'integer|string' } },
@@ -3622,7 +3620,7 @@ M.funcs = {
|v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
|getmousepos()| can also be used. Mouse move events will be
ignored.
- This example positions the mouse as it would normally happen: >
+ This example positions the mouse as it would normally happen: >vim
let c = getchar()
if c == "\<LeftMouse>" && v:mouse_win > 0
exe v:mouse_win .. "wincmd w"
@@ -3637,20 +3635,20 @@ M.funcs = {
There is no mapping for the character.
Key codes are replaced, thus when the user presses the <Del>
key you get the code for the <Del> key, not the raw character
- sequence. Examples: >
+ sequence. Examples: >vim
getchar() == "\<Del>"
getchar() == "\<S-Left>"
- <This example redefines "f" to ignore case: >
- :nmap f :call FindChar()<CR>
- :function FindChar()
- : let c = nr2char(getchar())
- : while col('.') < col('$') - 1
- : normal l
- : if getline('.')[col('.') - 1] ==? c
- : break
- : endif
- : endwhile
- :endfunction
+ <This example redefines "f" to ignore case: >vim
+ nmap f :call FindChar()<CR>
+ function FindChar()
+ let c = nr2char(getchar())
+ while col('.') < col('$') - 1
+ normal l
+ if getline('.')[col('.') - 1] ==? c
+ break
+ endif
+ endwhile
+ endfunction
<
]=],
name = 'getchar',
@@ -3692,13 +3690,13 @@ M.funcs = {
of the last character.
Example:
- With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >
+ With the cursor on 'μ„Έ' in line 5 with text "μ—¬λ³΄μ„Έμš”": >vim
getcharpos('.') returns [0, 5, 3, 0]
getpos('.') returns [0, 5, 7, 0]
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMark()->getcharpos()
-
+ <
]=],
name = 'getcharpos',
params = { { 'expr', 'any' } },
@@ -3721,9 +3719,9 @@ M.funcs = {
This can be useful to always have |;| and |,| search
forward/backward regardless of the direction of the previous
- character search: >
- :nnoremap <expr> ; getcharsearch().forward ? ';' : ','
- :nnoremap <expr> , getcharsearch().forward ? ',' : ';'
+ character search: >vim
+ nnoremap <expr> ; getcharsearch().forward ? ';' : ','
+ nnoremap <expr> , getcharsearch().forward ? ',' : ';'
<Also see |setcharsearch()|.
]=],
name = 'getcharsearch',
@@ -3744,7 +3742,6 @@ M.funcs = {
if no character is available.
Otherwise this works like |getchar()|, except that a number
result is converted to a string.
-
]=],
name = 'getcharstr',
params = {},
@@ -3760,7 +3757,6 @@ M.funcs = {
Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and
|setcmdline()|.
Returns an empty string when completion is not defined.
-
]=],
name = 'getcmdcompltype',
params = {},
@@ -3772,8 +3768,8 @@ M.funcs = {
Return the current command-line. Only works when the command
line is being edited, thus requires use of |c_CTRL-\_e| or
|c_CTRL-R_=|.
- Example: >
- :cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
+ Example: >vim
+ cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
<Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and
|setcmdline()|.
Returns an empty string when entering a password or using
@@ -3809,7 +3805,6 @@ M.funcs = {
Returns 0 otherwise.
Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and
|setcmdline()|.
-
]=],
name = 'getcmdscreenpos',
params = {},
@@ -3910,13 +3905,13 @@ M.funcs = {
If {type} is "cmdline", then the |cmdline-completion| result is
returned. For example, to complete the possible values after
- a ":call" command: >
+ a ":call" command: >vim
echo getcompletion('call ', 'cmdline')
<
If there are no matches, an empty list is returned. An
invalid value for {type} produces an error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPattern()->getcompletion('color')
<
]=],
@@ -3946,14 +3941,14 @@ M.funcs = {
current value of the buffer if it is not the current window.
If {winid} is invalid a list with zeroes is returned.
- This can be used to save and restore the cursor position: >
+ This can be used to save and restore the cursor position: >vim
let save_cursor = getcurpos()
MoveTheCursorAround
call setpos('.', save_cursor)
<Note that this only works within the window. See
|winrestview()| for restoring more state.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->getcurpos()
<
]=],
@@ -3969,13 +3964,13 @@ M.funcs = {
List is a character index instead of a byte index.
Example:
- With the cursor on '보' in line 3 with text "μ—¬λ³΄μ„Έμš”": >
- getcursorcharpos() returns [0, 3, 2, 0, 3]
- getcurpos() returns [0, 3, 4, 0, 3]
+ With the cursor on '보' in line 3 with text "μ—¬λ³΄μ„Έμš”": >vim
+ getcursorcharpos() " returns [0, 3, 2, 0, 3]
+ getcurpos() " returns [0, 3, 4, 0, 3]
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->getcursorcharpos()
-
+ <
]=],
name = 'getcursorcharpos',
params = { { 'winid', 'integer' } },
@@ -3991,7 +3986,7 @@ M.funcs = {
ignored.
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing tab number implies 0.
- Thus the following are equivalent: >
+ Thus the following are equivalent: >vim
getcwd(0)
getcwd(0, 0)
<If {winnr} is -1 it is ignored, only the tab is resolved.
@@ -4000,9 +3995,9 @@ M.funcs = {
directory is returned.
Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->getcwd()
-
+ <
]=],
name = 'getcwd',
params = { { 'winnr', 'integer' }, { 'tabnr', 'integer' } },
@@ -4014,16 +4009,16 @@ M.funcs = {
base = 1,
desc = [=[
Return the value of environment variable {name}. The {name}
- argument is a string, without a leading '$'. Example: >
+ argument is a string, without a leading '$'. Example: >vim
myHome = getenv('HOME')
<When the variable does not exist |v:null| is returned. That
is different from a variable set to an empty string.
See also |expr-env|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetVarname()->getenv()
-
+ <
]=],
name = 'getenv',
params = { { 'name', 'string' } },
@@ -4043,7 +4038,6 @@ M.funcs = {
Only works when the GUI is running, thus not in your vimrc or
gvimrc file. Use the |GUIEnter| autocommand to use this
function just after the GUI has started.
-
]=],
name = 'getfontname',
params = { { 'name', 'string' } },
@@ -4062,17 +4056,16 @@ M.funcs = {
"rwx" flags represent, in turn, the permissions of the owner
of the file, the group the file belongs to, and other users.
If a user does not have a given permission the flag for this
- is replaced with the string "-". Examples: >
- :echo getfperm("/etc/passwd")
- :echo getfperm(expand("~/.config/nvim/init.vim"))
+ is replaced with the string "-". Examples: >vim
+ echo getfperm("/etc/passwd")
+ echo getfperm(expand("~/.config/nvim/init.vim"))
<This will hopefully (from a security point of view) display
the string "rw-r--r--" or even "rw-------".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getfperm()
<
For setting permissions use |setfperm()|.
-
]=],
fast = true,
name = 'getfperm',
@@ -4091,9 +4084,9 @@ M.funcs = {
If the size of {fname} is too big to fit in a Number then -2
is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getfsize()
-
+ <
]=],
fast = true,
name = 'getfsize',
@@ -4111,9 +4104,9 @@ M.funcs = {
|localtime()| and |strftime()|.
If the file {fname} can't be found -1 is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getftime()
-
+ <
]=],
fast = true,
name = 'getftime',
@@ -4138,14 +4131,15 @@ M.funcs = {
Socket "socket"
FIFO "fifo"
All other "other"
- Example: >
+ Example: >vim
getftype("/home")
<Note that a type such as "link" will only be returned on
systems that support it. On some systems only "dir" and
"file" are returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->getftype()
+ <
]=],
fast = true,
name = 'getftype',
@@ -4176,7 +4170,7 @@ M.funcs = {
filename filename if available
lnum line number
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->getjumplist()
<
]=],
@@ -4189,11 +4183,11 @@ M.funcs = {
base = 1,
desc = [=[
Without {end} the result is a String, which is line {lnum}
- from the current buffer. Example: >
+ from the current buffer. Example: >vim
getline(1)
<When {lnum} is a String that doesn't start with a
digit, |line()| is called to translate the String into a Number.
- To get the line under the cursor: >
+ To get the line under the cursor: >vim
getline(".")
<When {lnum} is a number smaller than 1 or bigger than the
number of lines in the buffer, an empty string is returned.
@@ -4204,12 +4198,12 @@ M.funcs = {
{end} is used in the same way as {lnum}.
Non-existing lines are silently omitted.
When {end} is before {lnum} an empty |List| is returned.
- Example: >
- :let start = line('.')
- :let end = search("^$") - 1
- :let lines = getline(start, end)
+ Example: >vim
+ let start = line('.')
+ let end = search("^$") - 1
+ let lines = getline(start, end)
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
ComputeLnum()->getline()
<To get lines from another buffer see |getbufline()| and
@@ -4249,9 +4243,9 @@ M.funcs = {
location list for the window {nr}.
Returns an empty Dictionary if window {nr} does not exist.
- Examples (See also |getqflist-examples|): >
- :echo getloclist(3, {'all': 0})
- :echo getloclist(5, {'filewinid': 0})
+ Examples (See also |getqflist-examples|): >vim
+ echo getloclist(3, {'all': 0})
+ echo getloclist(5, {'filewinid': 0})
<
]=],
name = 'getloclist',
@@ -4280,9 +4274,9 @@ M.funcs = {
Refer to |getpos()| for getting information about a specific
mark.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->getmarklist()
-
+ <
]=],
name = 'getmarklist',
params = { { 'buf', 'any' } },
@@ -4300,26 +4294,26 @@ M.funcs = {
window ID instead of the current window. If {win} is invalid,
an empty list is returned.
Example: >vim
- :echo getmatches()
+ echo getmatches()
< >
[{"group": "MyGroup1", "pattern": "TODO",
"priority": 10, "id": 1}, {"group": "MyGroup2",
"pattern": "FIXME", "priority": 10, "id": 2}]
< >vim
- :let m = getmatches()
- :call clearmatches()
- :echo getmatches()
+ let m = getmatches()
+ call clearmatches()
+ echo getmatches()
< >
[]
< >vim
- :call setmatches(m)
- :echo getmatches()
+ call setmatches(m)
+ echo getmatches()
< >
[{"group": "MyGroup1", "pattern": "TODO",
"priority": 10, "id": 1}, {"group": "MyGroup2",
"pattern": "FIXME", "priority": 10, "id": 2}]
< >vim
- :unlet m
+ unlet m
<
]=],
name = 'getmatches',
@@ -4397,14 +4391,15 @@ M.funcs = {
A very large column number equal to |v:maxcol| can be returned,
in which case it means "after the end of the line".
If {expr} is invalid, returns a list with all zeros.
- This can be used to save and restore the position of a mark: >
+ This can be used to save and restore the position of a mark: >vim
let save_a_mark = getpos("'a")
- ...
+ " ...
call setpos("'a", save_a_mark)
<Also see |getcharpos()|, |getcurpos()| and |setpos()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMark()->getpos()
+ <
]=],
name = 'getpos',
params = { { 'expr', 'any' } },
@@ -4438,11 +4433,11 @@ M.funcs = {
you may need to explicitly check for zero).
Useful application: Find pattern matches in multiple files and
- do something with them: >
- :vimgrep /theword/jg *.c
- :for d in getqflist()
- : echo bufname(d.bufnr) ':' d.lnum '=' d.text
- :endfor
+ do something with them: >vim
+ vimgrep /theword/jg *.c
+ for d in getqflist()
+ echo bufname(d.bufnr) ':' d.lnum '=' d.text
+ endfor
<
If the optional {what} dictionary argument is supplied, then
returns only the items listed in {what} as a dictionary. The
@@ -4507,10 +4502,10 @@ M.funcs = {
to "".
winid quickfix |window-ID|. If not present, set to 0
- Examples (See also |getqflist-examples|): >
- :echo getqflist({'all': 1})
- :echo getqflist({'nr': 2, 'title': 1})
- :echo getqflist({'lines' : ["F1:10:L10"]})
+ Examples (See also |getqflist-examples|): >vim
+ echo getqflist({'all': 1})
+ echo getqflist({'nr': 2, 'title': 1})
+ echo getqflist({'lines' : ["F1:10:L10"]})
<
]=],
name = 'getqflist',
@@ -4522,8 +4517,8 @@ M.funcs = {
base = 1,
desc = [=[
The result is a String, which is the contents of register
- {regname}. Example: >
- :let cliptext = getreg('*')
+ {regname}. Example: >vim
+ let cliptext = getreg('*')
<When register {regname} was not set the result is an empty
string.
The {regname} argument must be a string.
@@ -4543,9 +4538,9 @@ M.funcs = {
If {regname} is not specified, |v:register| is used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRegname()->getreg()
-
+ <
]=],
name = 'getreg',
params = { { 'regname', 'string' }, { 'list', 'any' } },
@@ -4579,9 +4574,9 @@ M.funcs = {
If {regname} is not specified, |v:register| is used.
The returned Dictionary can be passed to |setreg()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRegname()->getreginfo()
-
+ <
]=],
name = 'getreginfo',
params = { { 'regname', 'string' } },
@@ -4602,9 +4597,9 @@ M.funcs = {
The {regname} argument is a string. If {regname} is not
specified, |v:register| is used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRegname()->getregtype()
-
+ <
]=],
name = 'getregtype',
params = { { 'regname', 'string' } },
@@ -4645,9 +4640,9 @@ M.funcs = {
this dictionary.
version Vimscript version, always 1
- Examples: >
- :echo getscriptinfo({'name': 'myscript'})
- :echo getscriptinfo({'sid': 15}).variables
+ Examples: >vim
+ echo getscriptinfo({'name': 'myscript'})
+ echo getscriptinfo({'sid': 15}).variables
<
]=],
name = 'getscriptinfo',
@@ -4670,9 +4665,9 @@ M.funcs = {
tabpage-local variables
windows List of |window-ID|s in the tab page.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->gettabinfo()
-
+ <
]=],
name = 'gettabinfo',
params = { { 'tabnr', 'integer' } },
@@ -4691,9 +4686,9 @@ M.funcs = {
When the tab or variable doesn't exist {def} or an empty
string is returned, there is no error message.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->gettabvar(varname)
-
+ <
]=],
name = 'gettabvar',
params = { { 'tabnr', 'integer' }, { 'varname', 'string' }, { 'def', 'any' } },
@@ -4721,16 +4716,16 @@ M.funcs = {
or buffer-local variable.
When the tab, window or variable doesn't exist {def} or an
empty string is returned, there is no error message.
- Examples: >
- :let list_is_on = gettabwinvar(1, 2, '&list')
- :echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
+ Examples: >vim
+ let list_is_on = gettabwinvar(1, 2, '&list')
+ echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
<
- To obtain all window-local variables use: >
+ To obtain all window-local variables use: >vim
gettabwinvar({tabnr}, {winnr}, '&')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->gettabwinvar(winnr, varname)
-
+ <
]=],
name = 'gettabwinvar',
params = {
@@ -4772,7 +4767,7 @@ M.funcs = {
See |tagstack| for more information about the tag stack.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->gettagstack()
<
]=],
@@ -4835,9 +4830,9 @@ M.funcs = {
winrow topmost screen line of the window;
"row" from |win_screenpos()|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->getwininfo()
-
+ <
]=],
name = 'getwininfo',
params = { { 'winid', 'integer' } },
@@ -4857,7 +4852,7 @@ M.funcs = {
When using a value less than 10 and no response is received
within that time, a previously reported position is returned,
if available. This can be used to poll for the position and
- do some work in the meantime: >
+ do some work in the meantime: >vim
while 1
let res = getwinpos(1)
if res[0] >= 0
@@ -4866,7 +4861,7 @@ M.funcs = {
" Do some work here
endwhile
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimeout()->getwinpos()
<
]=],
@@ -4892,7 +4887,6 @@ M.funcs = {
the top of the GUI Vim window. The result will be -1 if the
information is not available.
The value can be used with `:winpos`.
-
]=],
name = 'getwinposy',
params = {},
@@ -4904,11 +4898,11 @@ M.funcs = {
base = 1,
desc = [=[
Like |gettabwinvar()| for the current tabpage.
- Examples: >
- :let list_is_on = getwinvar(2, '&list')
- :echo "myvar = " .. getwinvar(1, 'myvar')
+ Examples: >vim
+ let list_is_on = getwinvar(2, '&list')
+ echo "myvar = " .. getwinvar(1, 'myvar')
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetWinnr()->getwinvar(varname)
<
]=],
@@ -4946,18 +4940,18 @@ M.funcs = {
|TRUE| then all symbolic links are included.
For most systems backticks can be used to get files names from
- any external command. Example: >
- :let tagfiles = glob("`find . -name tags -print`")
- :let &tags = substitute(tagfiles, "\n", ",", "g")
+ any external command. Example: >vim
+ let tagfiles = glob("`find . -name tags -print`")
+ let &tags = substitute(tagfiles, "\n", ",", "g")
<The result of the program inside the backticks should be one
item per line. Spaces inside an item are allowed.
See |expand()| for expanding special Vim variables. See
|system()| for getting the raw output of an external command.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->glob()
-
+ <
]=],
name = 'glob',
params = { { 'expr', 'any' }, { 'nosuf', 'boolean' }, { 'list', 'any' }, { 'alllinks', 'any' } },
@@ -4969,16 +4963,20 @@ M.funcs = {
desc = [=[
Convert a file pattern, as used by glob(), into a search
pattern. The result can be used to match with a string that
- is a file name. E.g. >
+ is a file name. E.g. >vim
if filename =~ glob2regpat('Make*.mak')
- <This is equivalent to: >
+ " ...
+ endif
+ <This is equivalent to: >vim
if filename =~ '^Make.*\.mak$'
+ " ...
+ endif
<When {string} is an empty string the result is "^$", match an
empty string.
Note that the result depends on the system. On MS-Windows
a backslash usually means a path separator.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->glob2regpat()
<
]=],
@@ -4991,8 +4989,8 @@ M.funcs = {
base = 2,
desc = [=[
Perform glob() for String {expr} on all directories in {path}
- and concatenate the results. Example: >
- :echo globpath(&rtp, "syntax/c.vim")
+ and concatenate the results. Example: >vim
+ echo globpath(&rtp, "syntax/c.vim")
<
{path} is a comma-separated list of directory names. Each
directory name is prepended to {expr} and expanded like with
@@ -5012,20 +5010,20 @@ M.funcs = {
with all matching files. The advantage of using a List is, you
also get filenames containing newlines correctly. Otherwise
the result is a String and when there are several matches,
- they are separated by <NL> characters. Example: >
- :echo globpath(&rtp, "syntax/c.vim", 0, 1)
+ they are separated by <NL> characters. Example: >vim
+ echo globpath(&rtp, "syntax/c.vim", 0, 1)
<
{allinks} is used as with |glob()|.
The "**" item can be used to search in a directory tree.
For example, to find all "README.txt" files in the directories
- in 'runtimepath' and below: >
- :echo globpath(&rtp, "**/README.txt")
+ in 'runtimepath' and below: >vim
+ echo globpath(&rtp, "**/README.txt")
<Upwards search and limiting the depth of "**" is not
supported, thus using 'path' will not always work properly.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetExpr()->globpath(&rtp)
<
]=],
@@ -5051,9 +5049,9 @@ M.funcs = {
<If the code has a syntax error then Vimscript may skip the
rest of the line. Put |:if| and |:endif| on separate lines to
- avoid the syntax error: >
+ avoid the syntax error: >vim
if has('feature')
- let x = this->breaks->without->the->feature
+ let x = this_breaks_without_the_feature()
endif
<
Vim's compile-time feature-names (prefixed with "+") are not
@@ -5062,12 +5060,16 @@ M.funcs = {
Feature names can be:
1. Nvim version. For example the "nvim-0.2.1" feature means
- that Nvim is version 0.2.1 or later: >
- :if has("nvim-0.2.1")
+ that Nvim is version 0.2.1 or later: >vim
+ if has("nvim-0.2.1")
+ " ...
+ endif
<2. Runtime condition or other pseudo-feature. For example the
- "win32" feature checks if the current system is Windows: >
- :if has("win32")
+ "win32" feature checks if the current system is Windows: >vim
+ if has("win32")
+ " ...
+ endif
< *feature-list*
List of supported pseudo-feature names:
acl |ACL| support.
@@ -5093,12 +5095,16 @@ M.funcs = {
*has-patch*
3. Vim patch. For example the "patch123" feature means that
- Vim patch 123 at the current |v:version| was included: >
- :if v:version > 602 || v:version == 602 && has("patch148")
+ Vim patch 123 at the current |v:version| was included: >vim
+ if v:version > 602 || v:version == 602 && has("patch148")
+ " ...
+ endif
<4. Vim version. For example the "patch-7.4.237" feature means
- that Nvim is Vim-compatible to version 7.4.237 or later. >
- :if has("patch-7.4.237")
+ that Nvim is Vim-compatible to version 7.4.237 or later. >vim
+ if has("patch-7.4.237")
+ " ...
+ endif
<
]=],
name = 'has',
@@ -5114,9 +5120,9 @@ M.funcs = {
has an entry with key {key}. FALSE otherwise. The {key}
argument is a string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mydict->has_key(key)
-
+ <
]=],
name = 'has_key',
params = { { 'dict', 'any' }, { 'key', 'any' } },
@@ -5133,19 +5139,19 @@ M.funcs = {
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing argument implies 0.
- Thus the following are equivalent: >
- haslocaldir()
- haslocaldir(0)
- haslocaldir(0, 0)
+ Thus the following are equivalent: >vim
+ echo haslocaldir()
+ echo haslocaldir(0)
+ echo haslocaldir(0, 0)
<With {winnr} use that window in the current tabpage.
With {winnr} and {tabnr} use the window in that tabpage.
{winnr} can be the window number or the |window-ID|.
If {winnr} is -1 it is ignored, only the tab is resolved.
Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->haslocaldir()
-
+ <
]=],
name = 'haslocaldir',
params = { { 'winnr', 'integer' }, { 'tabnr', 'integer' } },
@@ -5179,16 +5185,16 @@ M.funcs = {
When {mode} is omitted, "nvo" is used.
This function is useful to check if a mapping already exists
- to a function in a Vim script. Example: >
- :if !hasmapto('\ABCdoit')
- : map <Leader>d \ABCdoit
- :endif
+ to a function in a Vim script. Example: >vim
+ if !hasmapto('\ABCdoit')
+ map <Leader>d \ABCdoit
+ endif
<This installs the mapping to "\ABCdoit" only if there isn't
already a mapping to "\ABCdoit".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRHS()->hasmapto()
-
+ <
]=],
name = 'hasmapto',
params = { { 'what', 'any' }, { 'mode', 'string' }, { 'abbr', 'any' } },
@@ -5236,15 +5242,15 @@ M.funcs = {
The result is a Number: TRUE if the operation was successful,
otherwise FALSE is returned.
- Example: >
- :call histadd("input", strftime("%Y %b %d"))
- :let date=input("Enter date: ")
+ Example: >vim
+ call histadd("input", strftime("%Y %b %d"))
+ let date=input("Enter date: ")
<This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetHistory()->histadd('search')
-
+ <
]=],
name = 'histadd',
params = { { 'history', 'any' }, { 'item', 'any' } },
@@ -5270,25 +5276,25 @@ M.funcs = {
is returned.
Examples:
- Clear expression register history: >
- :call histdel("expr")
+ Clear expression register history: >vim
+ call histdel("expr")
<
- Remove all entries starting with "*" from the search history: >
- :call histdel("/", '^\*')
+ Remove all entries starting with "*" from the search history: >vim
+ call histdel("/", '^\*')
<
- The following three are equivalent: >
- :call histdel("search", histnr("search"))
- :call histdel("search", -1)
- :call histdel("search", '^' .. histget("search", -1) .. '$')
+ The following three are equivalent: >vim
+ call histdel("search", histnr("search"))
+ call histdel("search", -1)
+ call histdel("search", '^' .. histget("search", -1) .. '$')
<
To delete the last search pattern and use the last-but-one for
- the "n" command and 'hlsearch': >
- :call histdel("search", -1)
- :let @/ = histget("search", -1)
+ the "n" command and 'hlsearch': >vim
+ call histdel("search", -1)
+ let @/ = histget("search", -1)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHistory()->histdel()
-
+ <
]=],
name = 'histdel',
params = { { 'history', 'any' }, { 'item', 'any' } },
@@ -5306,16 +5312,16 @@ M.funcs = {
omitted, the most recent item from the history is used.
Examples:
- Redo the second last search from history. >
- :execute '/' .. histget("search", -2)
+ Redo the second last search from history. >vim
+ execute '/' .. histget("search", -2)
<Define an Ex command ":H {num}" that supports re-execution of
- the {num}th entry from the output of |:history|. >
- :command -nargs=1 H execute histget("cmd", 0+<args>)
+ the {num}th entry from the output of |:history|. >vim
+ command -nargs=1 H execute histget("cmd", 0+<args>)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHistory()->histget()
-
+ <
]=],
name = 'histget',
params = { { 'history', 'any' }, { 'index', 'any' } },
@@ -5330,10 +5336,10 @@ M.funcs = {
See |hist-names| for the possible values of {history}.
If an error occurred, -1 is returned.
- Example: >
- :let inp_index = histnr("expr")
+ Example: >vim
+ let inp_index = histnr("expr")
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetHistory()->histnr()
<
]=],
@@ -5351,12 +5357,12 @@ M.funcs = {
zero is returned.
This can be used to retrieve information about the highlight
group. For example, to get the background color of the
- "Comment" group: >
- :echo synIDattr(synIDtrans(hlID("Comment")), "bg")
+ "Comment" group: >vim
+ echo synIDattr(synIDtrans(hlID("Comment")), "bg")
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->hlID()
-
+ <
]=],
name = 'hlID',
params = { { 'name', 'string' } },
@@ -5373,7 +5379,7 @@ M.funcs = {
been defined for it, it may also have been used for a syntax
item.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->hlexists()
<
]=],
@@ -5387,7 +5393,6 @@ M.funcs = {
The result is a String, which is the name of the machine on
which Vim is currently running. Machine names greater than
256 characters long are truncated.
-
]=],
fast = true,
name = 'hostname',
@@ -5410,7 +5415,7 @@ M.funcs = {
from/to UCS-2 is automatically changed to use UTF-8. You
cannot use UCS-2 in a string anyway, because of the NUL bytes.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->iconv('latin1', 'utf-8')
<
]=],
@@ -5426,8 +5431,8 @@ M.funcs = {
container type (|List|, |Dict|, |Blob| and |Partial|). It is
guaranteed that for the mentioned types `id(v1) ==# id(v2)`
returns true iff `type(v1) == type(v2) && v1 is v2`.
- Note that |v:_null_string|, |v:_null_list|, |v:_null_dict| and
- |v:_null_blob| have the same `id()` with different types
+ Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
+ `v:_null_blob` have the same `id()` with different types
because they are internally represented as NULL pointers.
`id()` returns a hexadecimal representanion of the pointers to
the containers (i.e. like `0x994a40`), same as `printf("%p",
@@ -5437,7 +5442,6 @@ M.funcs = {
It is not guaranteed that `id(no_longer_existing_container)`
will not be equal to some other `id()`: new containers may
reuse identifiers of the garbage-collected ones.
-
]=],
name = 'id',
params = { { 'expr', 'any' } },
@@ -5452,9 +5456,9 @@ M.funcs = {
|getline()|.
When {lnum} is invalid -1 is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->indent()
-
+ <
]=],
name = 'indent',
params = { { 'lnum', 'integer' } },
@@ -5485,13 +5489,15 @@ M.funcs = {
case must match.
-1 is returned when {expr} is not found in {object}.
- Example: >
- :let idx = index(words, "the")
- :if index(numbers, 123) >= 0
+ Example: >vim
+ let idx = index(words, "the")
+ if index(numbers, 123) >= 0
+ " ...
+ endif
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetObject()->index(what)
-
+ <
]=],
name = 'index',
params = { { 'object', 'any' }, { 'expr', 'any' }, { 'start', 'any' }, { 'ic', 'any' } },
@@ -5532,15 +5538,15 @@ M.funcs = {
index; may be negative for an item relative to
the end
Returns -1 when {expr} evaluates to v:false for all the items.
- Example: >
- :let l = [#{n: 10}, #{n: 20}, #{n: 30}]
- :echo indexof(l, "v:val.n == 20")
- :echo indexof(l, {i, v -> v.n == 30})
- :echo indexof(l, "v:val.n == 20", #{startidx: 1})
+ Example: >vim
+ let l = [#{n: 10}, #{n: 20}, #{n: 30}]
+ echo indexof(l, "v:val.n == 20")
+ echo indexof(l, {i, v -> v.n == 30})
+ echo indexof(l, "v:val.n == 20", #{startidx: 1})
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
mylist->indexof(expr)
-
+ <
]=],
name = 'indexof',
params = { { 'object', 'any' }, { 'expr', 'any' }, { 'opts', 'table' } },
@@ -5578,22 +5584,22 @@ M.funcs = {
The input is entered just like a command-line, with the same
editing commands and mappings. There is a separate history
for lines typed for input().
- Example: >
- :if input("Coffee or beer? ") == "beer"
- : echo "Cheers!"
- :endif
+ Example: >vim
+ if input("Coffee or beer? ") == "beer"
+ echo "Cheers!"
+ endif
<
If the optional {text} argument is present and not empty, this
is used for the default reply, as if the user typed this.
- Example: >
- :let color = input("Color? ", "white")
+ Example: >vim
+ let color = input("Color? ", "white")
<The optional {completion} argument specifies the type of
completion supported for the input. Without it completion is
not performed. The supported completion types are the same as
that can be supplied to a user-defined command using the
"-complete=" argument. Refer to |:command-completion| for
- more information. Example: >
+ more information. Example: >vim
let fname = input("File: ", "", "file")
< *input()-highlight* *E5400* *E5402*
@@ -5614,7 +5620,7 @@ M.funcs = {
sections must be ordered so that next hl_start_col is greater
then or equal to previous hl_end_col.
- Example (try some input with parentheses): >
+ Example (try some input with parentheses): >vim
highlight RBP1 guibg=Red ctermbg=red
highlight RBP2 guibg=Yellow ctermbg=yellow
highlight RBP3 guibg=Green ctermbg=green
@@ -5659,17 +5665,17 @@ M.funcs = {
that further characters follow in the mapping, e.g., by using
|:execute| or |:normal|.
- Example with a mapping: >
- :nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
- :function GetFoo()
- : call inputsave()
- : let g:Foo = input("enter search pattern: ")
- : call inputrestore()
- :endfunction
+ Example with a mapping: >vim
+ nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
+ function GetFoo()
+ call inputsave()
+ let g:Foo = input("enter search pattern: ")
+ call inputrestore()
+ endfunction
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetPrompt()->input()
-
+ <
]=],
name = 'input',
params = { { 'opts', 'table' } },
@@ -5701,13 +5707,13 @@ M.funcs = {
Make sure {textlist} has less than 'lines' entries, otherwise
it won't work. It's a good idea to put the entry number at
the start of the string. And put a prompt in the first item.
- Example: >
+ Example: >vim
let color = inputlist(['Select color:', '1. red',
\ '2. green', '3. blue'])
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetChoices()->inputlist()
-
+ <
]=],
name = 'inputlist',
params = { { 'textlist', 'any' } },
@@ -5719,7 +5725,6 @@ M.funcs = {
Should be called the same number of times inputsave() is
called. Calling it more often is harmless though.
Returns TRUE when there is nothing to restore, FALSE otherwise.
-
]=],
name = 'inputrestore',
params = {},
@@ -5733,7 +5738,6 @@ M.funcs = {
be used several times, in which case there must be just as
many inputrestore() calls.
Returns TRUE when out of memory, FALSE otherwise.
-
]=],
name = 'inputsave',
params = {},
@@ -5753,9 +5757,9 @@ M.funcs = {
typed on the command-line in response to the issued prompt.
NOTE: Command-line completion is not supported.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPrompt()->inputsecret()
-
+ <
]=],
name = 'inputsecret',
params = { { 'prompt', 'any' }, { 'text', 'any' } },
@@ -5773,17 +5777,17 @@ M.funcs = {
like omitting {idx}. A negative {idx} is also possible, see
|list-index|. -1 inserts just before the last item.
- Returns the resulting |List| or |Blob|. Examples: >
- :let mylist = insert([2, 3, 5], 1)
- :call insert(mylist, 4, -1)
- :call insert(mylist, 6, len(mylist))
+ Returns the resulting |List| or |Blob|. Examples: >vim
+ let mylist = insert([2, 3, 5], 1)
+ call insert(mylist, 4, -1)
+ call insert(mylist, 6, len(mylist))
<The last example can be done simpler with |add()|.
Note that when {item} is a |List| it is inserted as a single
item. Use |extend()| to concatenate |Lists|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->insert(item)
-
+ <
]=],
name = 'insert',
params = { { 'object', 'any' }, { 'item', 'any' }, { 'idx', 'integer' } },
@@ -5795,15 +5799,15 @@ M.funcs = {
Interrupt script execution. It works more or less like the
user typing CTRL-C, most commands won't execute and control
returns to the user. This is useful to abort execution
- from lower down, e.g. in an autocommand. Example: >
- :function s:check_typoname(file)
- : if fnamemodify(a:file, ':t') == '['
- : echomsg 'Maybe typo'
- : call interrupt()
- : endif
- :endfunction
- :au BufWritePre * call s:check_typoname(expand('<amatch>'))
-
+ from lower down, e.g. in an autocommand. Example: >vim
+ function s:check_typoname(file)
+ if fnamemodify(a:file, ':t') == '['
+ echomsg 'Maybe typo'
+ call interrupt()
+ endif
+ endfunction
+ au BufWritePre * call s:check_typoname(expand('<amatch>'))
+ <
]=],
name = 'interrupt',
params = {},
@@ -5814,11 +5818,11 @@ M.funcs = {
base = 1,
desc = [=[
Bitwise invert. The argument is converted to a number. A
- List, Dict or Float argument causes an error. Example: >
- :let bits = invert(bits)
- <Can also be used as a |method|: >
- :let bits = bits->invert()
-
+ List, Dict or Float argument causes an error. Example: >vim
+ let bits = invert(bits)
+ <Can also be used as a |method|: >vim
+ let bits = bits->invert()
+ <
]=],
name = 'invert',
params = { { 'expr', 'any' } },
@@ -5833,9 +5837,9 @@ M.funcs = {
exist, or isn't a directory, the result is |FALSE|. {directory}
is any expression, which is used as a String.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->isdirectory()
-
+ <
]=],
fast = true,
name = 'isdirectory',
@@ -5848,15 +5852,15 @@ M.funcs = {
base = 1,
desc = [=[
Return 1 if {expr} is a positive infinity, or -1 a negative
- infinity, otherwise 0. >
- :echo isinf(1.0 / 0.0)
- < 1 >
- :echo isinf(-1.0 / 0.0)
+ infinity, otherwise 0. >vim
+ echo isinf(1.0 / 0.0)
+ < 1 >vim
+ echo isinf(-1.0 / 0.0)
< -1
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->isinf()
-
+ <
]=],
name = 'isinf',
params = { { 'expr', 'any' } },
@@ -5871,18 +5875,18 @@ M.funcs = {
name of a locked variable.
The string argument {expr} must be the name of a variable,
|List| item or |Dictionary| entry, not the variable itself!
- Example: >
- :let alist = [0, ['a', 'b'], 2, 3]
- :lockvar 1 alist
- :echo islocked('alist') " 1
- :echo islocked('alist[1]') " 0
+ Example: >vim
+ let alist = [0, ['a', 'b'], 2, 3]
+ lockvar 1 alist
+ echo islocked('alist') " 1
+ echo islocked('alist[1]') " 0
<When {expr} is a variable that does not exist you get an error
message. Use |exists()| to check for existence.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->islocked()
-
+ <
]=],
name = 'islocked',
params = { { 'expr', 'any' } },
@@ -5894,13 +5898,13 @@ M.funcs = {
args = 1,
base = 1,
desc = [=[
- Return |TRUE| if {expr} is a float with value NaN. >
+ Return |TRUE| if {expr} is a float with value NaN. >vim
echo isnan(0.0 / 0.0)
< 1
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->isnan()
-
+ <
]=],
name = 'isnan',
params = { { 'expr', 'any' } },
@@ -5915,14 +5919,14 @@ M.funcs = {
|List| item is a list with two items: the key of a {dict}
entry and the value of this entry. The |List| is in arbitrary
order. Also see |keys()| and |values()|.
- Example: >
+ Example: >vim
for [key, value] in items(mydict)
echo key .. ': ' .. value
endfor
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
mydict->items()
-
+ <
]=],
name = 'items',
params = { { 'dict', 'any' } },
@@ -5942,7 +5946,6 @@ M.funcs = {
args = 1,
desc = [=[
Return the PID (process id) of |job-id| {job}.
-
]=],
name = 'jobpid',
params = { { 'job', 'any' } },
@@ -5955,7 +5958,6 @@ M.funcs = {
Resize the pseudo terminal window of |job-id| {job} to {width}
columns and {height} rows.
Fails if the job was not started with `"pty":v:true`.
-
]=],
name = 'jobresize',
params = { { 'job', 'any' }, { 'width', 'integer' }, { 'height', 'integer' } },
@@ -5978,12 +5980,12 @@ M.funcs = {
Spawns {cmd} as a job.
If {cmd} is a List it runs directly (no 'shell').
- If {cmd} is a String it runs in the 'shell', like this: >
- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+ If {cmd} is a String it runs in the 'shell', like this: >vim
+ call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
<(See |shell-unquoting| for details.)
- Example: >
- :call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
+ Example: >vim
+ call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
<
Returns |job-id| on success, 0 on invalid arguments (or job
table is full), -1 if {cmd}[0] or 'shell' is not executable.
@@ -5996,10 +5998,10 @@ M.funcs = {
NOTE: on Windows if {cmd} is a List:
- cmd[0] must be an executable (not a "built-in"). If it is
- in $PATH it can be called by name, without an extension: >
- :call jobstart(['ping', 'neovim.io'])
- < If it is a full or partial path, extension is required: >
- :call jobstart(['System32\ping.exe', 'neovim.io'])
+ in $PATH it can be called by name, without an extension: >vim
+ call jobstart(['ping', 'neovim.io'])
+ < If it is a full or partial path, extension is required: >vim
+ call jobstart(['System32\ping.exe', 'neovim.io'])
< - {cmd} is collapsed to a string of quoted args as expected
by CommandLineToArgvW https://msdn.microsoft.com/bb776391
unless cmd[0] is some form of "cmd.exe".
@@ -6058,7 +6060,6 @@ M.funcs = {
- 0 on invalid arguments
- -1 if {cmd}[0] is not executable.
See also |job-control|, |channel|, |msgpack-rpc|.
-
]=],
name = 'jobstart',
params = { { 'cmd', 'any' }, { 'opts', 'table' } },
@@ -6075,7 +6076,6 @@ M.funcs = {
Returns 1 for valid job id, 0 for invalid id, including jobs have
exited or stopped.
-
]=],
name = 'jobstop',
params = { { 'id', 'any' } },
@@ -6090,7 +6090,7 @@ M.funcs = {
{timeout} is the maximum waiting time in milliseconds. If
omitted or -1, wait forever.
- Timeout of 0 can be used to check the status of a job: >
+ Timeout of 0 can be used to check the status of a job: >vim
let running = jobwait([{job-id}], 0)[0] == -1
<
During jobwait() callbacks for jobs not in the {jobs} list may
@@ -6103,7 +6103,6 @@ M.funcs = {
-1 if the timeout was exceeded
-2 if the job was interrupted (by |CTRL-C|)
-3 if the job-id is invalid
-
]=],
name = 'jobwait',
params = { { 'jobs', 'any' }, { 'timeout', 'integer' } },
@@ -6117,15 +6116,15 @@ M.funcs = {
When {sep} is specified it is put in between the items. If
{sep} is omitted a single space is used.
Note that {sep} is not added at the end. You might want to
- add it there too: >
+ add it there too: >vim
let lines = join(mylist, "\n") .. "\n"
<String items are used as-is. |Lists| and |Dictionaries| are
converted into a string like with |string()|.
The opposite function is |split()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->join()
-
+ <
]=],
name = 'join',
params = { { 'list', 'any' }, { 'sep', 'any' } },
@@ -6150,9 +6149,9 @@ M.funcs = {
recommended and the only one required to be supported.
Non-UTF-8 characters are an error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
ReadObject()->json_decode()
-
+ <
]=],
name = 'json_decode',
params = { { 'expr', 'any' } },
@@ -6173,9 +6172,9 @@ M.funcs = {
or special escapes like "\t", other are dumped as-is.
|Blob|s are converted to arrays of the individual bytes.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetObject()->json_encode()
-
+ <
]=],
name = 'json_encode',
params = { { 'expr', 'any' } },
@@ -6188,9 +6187,9 @@ M.funcs = {
Return a |List| with all the keys of {dict}. The |List| is in
arbitrary order. Also see |items()| and |values()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mydict->keys()
-
+ <
]=],
name = 'keys',
params = { { 'dict', 'any' } },
@@ -6201,12 +6200,12 @@ M.funcs = {
base = 1,
desc = [=[
Turn the internal byte representation of keys into a form that
- can be used for |:map|. E.g. >
- :let xx = "\<C-Home>"
- :echo keytrans(xx)
+ can be used for |:map|. E.g. >vim
+ let xx = "\<C-Home>"
+ echo keytrans(xx)
< <C-Home>
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
"\<C-Home>"->keytrans()
<
]=],
@@ -6235,7 +6234,7 @@ M.funcs = {
|Dictionary| is returned.
Otherwise an error is given and returns zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->len()
<
]=],
@@ -6286,11 +6285,11 @@ M.funcs = {
the DLL is not in the usual places.
For Unix: When compiling your own plugins, remember that the
object code must be compiled as position-independent ('PIC').
- Examples: >
- :echo libcall("libc.so", "getenv", "HOME")
+ Examples: >vim
+ echo libcall("libc.so", "getenv", "HOME")
<Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->libcall("libc.so", "getenv")
<
]=],
@@ -6305,13 +6304,13 @@ M.funcs = {
desc = [=[
Just like |libcall()|, but used for a function that returns an
int instead of a string.
- Examples: >
- :echo libcallnr("/usr/lib/libc.so", "getpid", "")
- :call libcallnr("libc.so", "printf", "Hello World!\n")
- :call libcallnr("libc.so", "sleep", 10)
+ Examples: >vim
+ echo libcallnr("/usr/lib/libc.so", "getpid", "")
+ call libcallnr("libc.so", "printf", "Hello World!\n")
+ call libcallnr("libc.so", "sleep", 10)
<
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->libcallnr("libc.so", "printf")
<
]=],
@@ -6345,18 +6344,18 @@ M.funcs = {
With the optional {winid} argument the values are obtained for
that window instead of the current window.
Returns 0 for invalid values of {expr} and {winid}.
- Examples: >
- line(".") line number of the cursor
- line(".", winid) idem, in window "winid"
- line("'t") line number of mark t
- line("'" .. marker) line number of mark marker
+ Examples: >vim
+ echo line(".") " line number of the cursor
+ echo line(".", winid) " idem, in window "winid"
+ echo line("'t") " line number of mark t
+ echo line("'" .. marker) " line number of mark marker
<
To jump to the last known position when opening a file see
|last-position-jump|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetValue()->line()
-
+ <
]=],
name = 'line',
params = { { 'expr', 'any' }, { 'winid', 'integer' } },
@@ -6372,16 +6371,16 @@ M.funcs = {
the 'fileformat' option for the current buffer. The first
line returns 1. UTF-8 encoding is used, 'fileencoding' is
ignored. This can also be used to get the byte count for the
- line just below the last line: >
- line2byte(line("$") + 1)
+ line just below the last line: >vim
+ echo line2byte(line("$") + 1)
<This is the buffer size plus one. If 'fileencoding' is empty
it is the file size plus one. {lnum} is used like with
|getline()|. When {lnum} is invalid -1 is returned.
Also see |byte2line()|, |go| and |:goto|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->line2byte()
-
+ <
]=],
name = 'line2byte',
params = { { 'lnum', 'integer' } },
@@ -6398,9 +6397,9 @@ M.funcs = {
relevant. {lnum} is used just like in |getline()|.
When {lnum} is invalid, -1 is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->lispindent()
-
+ <
]=],
name = 'lispindent',
params = { { 'lnum', 'integer' } },
@@ -6411,17 +6410,17 @@ M.funcs = {
base = 1,
desc = [=[
Return a Blob concatenating all the number values in {list}.
- Examples: >
- list2blob([1, 2, 3, 4]) returns 0z01020304
- list2blob([]) returns 0z
+ Examples: >vim
+ echo list2blob([1, 2, 3, 4]) " returns 0z01020304
+ echo list2blob([]) " returns 0z
<Returns an empty Blob on error. If one of the numbers is
negative or more than 255 error *E1239* is given.
|blob2list()| does the opposite.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetList()->list2blob()
-
+ <
]=],
name = 'list2blob',
params = { { 'list', 'any' } },
@@ -6432,23 +6431,23 @@ M.funcs = {
base = 1,
desc = [=[
Convert each number in {list} to a character string can
- concatenate them all. Examples: >
- list2str([32]) returns " "
- list2str([65, 66, 67]) returns "ABC"
- <The same can be done (slowly) with: >
- join(map(list, {nr, val -> nr2char(val)}), '')
+ concatenate them all. Examples: >vim
+ echo list2str([32]) " returns " "
+ echo list2str([65, 66, 67]) " returns "ABC"
+ <The same can be done (slowly) with: >vim
+ echo join(map(list, {nr, val -> nr2char(val)}), '')
<|str2list()| does the opposite.
UTF-8 encoding is always used, {utf8} option has no effect,
and exists only for backwards-compatibility.
- With UTF-8 composing characters work as expected: >
- list2str([97, 769]) returns "á"
+ With UTF-8 composing characters work as expected: >vim
+ echo list2str([97, 769]) " returns "á"
<
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetList()->list2str()
-
+ <
]=],
name = 'list2str',
params = { { 'list', 'any' }, { 'utf8', 'any' } },
@@ -6471,15 +6470,15 @@ M.funcs = {
{expr} must evaluate to a |Float| or a |Number| in the range
(0, inf].
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo log(10)
- < 2.302585 >
- :echo log(exp(5))
+ Examples: >vim
+ echo log(10)
+ < 2.302585 >vim
+ echo log(exp(5))
< 5.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->log()
-
+ <
]=],
float_func = 'log',
name = 'log',
@@ -6493,15 +6492,15 @@ M.funcs = {
Return the logarithm of Float {expr} to base 10 as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo log10(1000)
- < 3.0 >
- :echo log10(0.01)
+ Examples: >vim
+ echo log10(1000)
+ < 3.0 >vim
+ echo log10(0.01)
< -2.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->log10()
-
+ <
]=],
float_func = 'log10',
name = 'log10',
@@ -6515,7 +6514,7 @@ M.funcs = {
Evaluate Lua expression {expr} and return its result converted
to Vim data structures. See |lua-eval| for more details.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->luaeval()
<
]=],
@@ -6539,8 +6538,8 @@ M.funcs = {
of the current item and for a |List| |v:key| has the index of
the current item. For a |Blob| |v:key| has the index of the
current byte.
- Example: >
- :call map(mylist, '"> " .. v:val .. " <"')
+ Example: >vim
+ call map(mylist, '"> " .. v:val .. " <"')
<This puts "> " before and " <" after each item in "mylist".
Note that {expr2} is the result of an expression and is then
@@ -6552,21 +6551,21 @@ M.funcs = {
1. The key or the index of the current item.
2. the value of the current item.
The function must return the new value of the item. Example
- that changes each value by "key-value": >
+ that changes each value by "key-value": >vim
func KeyValue(key, val)
return a:key .. '-' .. a:val
endfunc
call map(myDict, function('KeyValue'))
- <It is shorter when using a |lambda|: >
+ <It is shorter when using a |lambda|: >vim
call map(myDict, {key, val -> key .. '-' .. val})
- <If you do not use "val" you can leave it out: >
+ <If you do not use "val" you can leave it out: >vim
call map(myDict, {key -> 'item: ' .. key})
- <If you do not use "key" you can use a short name: >
+ <If you do not use "key" you can use a short name: >vim
call map(myDict, {_, val -> 'item: ' .. val})
<
The operation is done in-place. If you want a |List| or
- |Dictionary| to remain unmodified make a copy first: >
- :let tlist = map(copy(mylist), ' v:val .. "\t"')
+ |Dictionary| to remain unmodified make a copy first: >vim
+ let tlist = map(copy(mylist), ' v:val .. "\t"')
<Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
filtered. When an error is encountered while evaluating
@@ -6574,7 +6573,7 @@ M.funcs = {
{expr2} is a Funcref errors inside a function are ignored,
unless it was defined with the "abort" flag.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->map(expr2)
<
]=],
@@ -6646,12 +6645,12 @@ M.funcs = {
The mappings local to the current buffer are checked first,
then the global mappings.
This function can be used to map a key even when it's already
- mapped, and have it do the original mapping too. Sketch: >
+ mapped, and have it do the original mapping too. Sketch: >vim
exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetKey()->maparg('n')
-
+ <
]=],
name = 'maparg',
params = { { 'name', 'string' }, { 'mode', 'string' }, { 'abbr', 'boolean' }, { 'dict', 'boolean' } },
@@ -6687,16 +6686,16 @@ M.funcs = {
The mappings local to the current buffer are checked first,
then the global mappings.
This function can be used to check if a mapping can be added
- without being ambiguous. Example: >
- :if mapcheck("_vv") == ""
- : map _vv :set guifont=7x13<CR>
- :endif
+ without being ambiguous. Example: >vim
+ if mapcheck("_vv") == ""
+ map _vv :set guifont=7x13<CR>
+ endif
<This avoids adding the "_vv" mapping when there already is a
mapping for "_v" or for "_vvv".
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetKey()->mapcheck('n')
-
+ <
]=],
name = 'mapcheck',
params = { { 'name', 'string' }, { 'mode', 'string' }, { 'abbr', 'any' } },
@@ -6711,10 +6710,10 @@ M.funcs = {
|maparg()|. *E460*
{mode} is used to define the mode in which the mapping is set,
not the "mode" entry in {dict}.
- Example for saving and restoring a mapping: >
+ Example for saving and restoring a mapping: >vim
let save_map = maparg('K', 'n', 0, 1)
nnoremap K somethingelse
- ...
+ " ...
call mapset('n', 0, save_map)
<Note that if you are going to replace a map in several modes,
e.g. with `:map!`, you need to save the mapping for all of
@@ -6740,27 +6739,27 @@ M.funcs = {
If there is no match -1 is returned.
For getting submatches see |matchlist()|.
- Example: >
- :echo match("testing", "ing") " results in 4
- :echo match([1, 'x'], '\a') " results in 1
+ Example: >vim
+ echo match("testing", "ing") " results in 4
+ echo match([1, 'x'], '\a') " results in 1
<See |string-match| for how {pat} is used.
*strpbrk()*
- Vim doesn't have a strpbrk() function. But you can do: >
- :let sepidx = match(line, '[.,;: \t]')
+ Vim doesn't have a strpbrk() function. But you can do: >vim
+ let sepidx = match(line, '[.,;: \t]')
< *strcasestr()*
Vim doesn't have a strcasestr() function. But you can add
- "\c" to the pattern to ignore case: >
- :let idx = match(haystack, '\cneedle')
+ "\c" to the pattern to ignore case: >vim
+ let idx = match(haystack, '\cneedle')
<
If {start} is given, the search starts from byte index
{start} in a String or item {start} in a |List|.
The result, however, is still the index counted from the
- first character/item. Example: >
- :echo match("testing", "ing", 2)
- <result is again "4". >
- :echo match("testing", "ing", 4)
- <result is again "4". >
- :echo match("testing", "t", 2)
+ first character/item. Example: >vim
+ echo match("testing", "ing", 2)
+ <result is again "4". >vim
+ echo match("testing", "ing", 4)
+ <result is again "4". >vim
+ echo match("testing", "t", 2)
<result is "3".
For a String, if {start} > 0 then it is like the string starts
{start} bytes later, thus "^" will match at {start}. Except
@@ -6774,7 +6773,7 @@ M.funcs = {
When {count} is given use the {count}th match. When a match
is found in a String the search for the next one starts one
- character further. Thus this example results in 1: >
+ character further. Thus this example results in 1: >vim
echo match("testing", "..", 0, 2)
<In a |List| the search continues in the next item.
Note that when {count} is added the way {start} works changes,
@@ -6789,7 +6788,7 @@ M.funcs = {
zero matches at the start instead of a number of matches
further down in the text.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->match('word')
GetList()->match('word')
<
@@ -6849,17 +6848,17 @@ M.funcs = {
Returns -1 on error.
- Example: >
- :highlight MyGroup ctermbg=green guibg=green
- :let m = matchadd("MyGroup", "TODO")
- <Deletion of the pattern: >
- :call matchdelete(m)
+ Example: >vim
+ highlight MyGroup ctermbg=green guibg=green
+ let m = matchadd("MyGroup", "TODO")
+ <Deletion of the pattern: >vim
+ call matchdelete(m)
<A list of matches defined by |matchadd()| and |:match| are
available from |getmatches()|. All matches can be deleted in
one operation by |clearmatches()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetGroup()->matchadd('TODO')
<
]=],
@@ -6905,18 +6904,18 @@ M.funcs = {
Returns -1 on error.
- Example: >
- :highlight MyGroup ctermbg=green guibg=green
- :let m = matchaddpos("MyGroup", [[23, 24], 34])
- <Deletion of the pattern: >
- :call matchdelete(m)
+ Example: >vim
+ highlight MyGroup ctermbg=green guibg=green
+ let m = matchaddpos("MyGroup", [[23, 24], 34])
+ <Deletion of the pattern: >vim
+ call matchdelete(m)
<Matches added by |matchaddpos()| are returned by
|getmatches()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetGroup()->matchaddpos([23, 11])
-
+ <
]=],
name = 'matchaddpos',
params = {
@@ -6943,9 +6942,9 @@ M.funcs = {
Highlighting matches using the |:match| commands are limited
to three matches. |matchadd()| does not have this limitation.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMatch()->matcharg()
-
+ <
]=],
name = 'matcharg',
params = { { 'nr', 'integer' } },
@@ -6962,9 +6961,9 @@ M.funcs = {
If {win} is specified, use the window with this number or
window ID instead of the current window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMatch()->matchdelete()
-
+ <
]=],
name = 'matchdelete',
params = { { 'id', 'any' }, { 'win', 'any' } },
@@ -6976,26 +6975,26 @@ M.funcs = {
base = 1,
desc = [=[
Same as |match()|, but return the index of first character
- after the match. Example: >
- :echo matchend("testing", "ing")
+ after the match. Example: >vim
+ echo matchend("testing", "ing")
<results in "7".
*strspn()* *strcspn()*
Vim doesn't have a strspn() or strcspn() function, but you can
- do it with matchend(): >
- :let span = matchend(line, '[a-zA-Z]')
- :let span = matchend(line, '[^a-zA-Z]')
+ do it with matchend(): >vim
+ let span = matchend(line, '[a-zA-Z]')
+ let span = matchend(line, '[^a-zA-Z]')
<Except that -1 is returned when there are no matches.
- The {start}, if given, has the same meaning as for |match()|. >
- :echo matchend("testing", "ing", 2)
- <results in "7". >
- :echo matchend("testing", "ing", 5)
+ The {start}, if given, has the same meaning as for |match()|. >vim
+ echo matchend("testing", "ing", 2)
+ <results in "7". >vim
+ echo matchend("testing", "ing", 5)
<result is "-1".
When {expr} is a |List| the result is equal to |match()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchend('word')
-
+ <
]=],
name = 'matchend',
params = { { 'expr', 'any' }, { 'pat', 'any' }, { 'start', 'any' }, { 'count', 'any' } },
@@ -7045,28 +7044,27 @@ M.funcs = {
Refer to |fuzzy-matching| for more information about fuzzy
matching strings.
- Example: >
- :echo matchfuzzy(["clay", "crow"], "cay")
- <results in ["clay"]. >
- :echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
- <results in a list of buffer names fuzzy matching "ndl". >
- :echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
+ Example: >vim
+ echo matchfuzzy(["clay", "crow"], "cay")
+ <results in ["clay"]. >vim
+ echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
+ <results in a list of buffer names fuzzy matching "ndl". >vim
+ echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
<results in a list of buffer information dicts with buffer
- names fuzzy matching "ndl". >
- :echo getbufinfo()->matchfuzzy("spl",
+ names fuzzy matching "ndl". >vim
+ echo getbufinfo()->matchfuzzy("spl",
\ {'text_cb' : {v -> v.name}})
<results in a list of buffer information dicts with buffer
- names fuzzy matching "spl". >
- :echo v:oldfiles->matchfuzzy("test")
- <results in a list of file names fuzzy matching "test". >
- :let l = readfile("buffer.c")->matchfuzzy("str")
- <results in a list of lines in "buffer.c" fuzzy matching "str". >
- :echo ['one two', 'two one']->matchfuzzy('two one')
- <results in `['two one', 'one two']` . >
- :echo ['one two', 'two one']->matchfuzzy('two one',
+ names fuzzy matching "spl". >vim
+ echo v:oldfiles->matchfuzzy("test")
+ <results in a list of file names fuzzy matching "test". >vim
+ let l = readfile("buffer.c")->matchfuzzy("str")
+ <results in a list of lines in "buffer.c" fuzzy matching "str". >vim
+ echo ['one two', 'two one']->matchfuzzy('two one')
+ <results in `['two one', 'one two']` . >vim
+ echo ['one two', 'two one']->matchfuzzy('two one',
\ {'matchseq': 1})
<results in `['two one']`.
-
]=],
name = 'matchfuzzy',
params = { { 'list', 'any' }, { 'str', 'any' }, { 'dict', 'any' } },
@@ -7088,15 +7086,14 @@ M.funcs = {
If there are no matching strings or there is an error, then a
list with three empty list items is returned.
- Example: >
- :echo matchfuzzypos(['testing'], 'tsg')
- <results in [["testing"], [[0, 2, 6]], [99]] >
- :echo matchfuzzypos(['clay', 'lacy'], 'la')
- <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >
- :echo [{'text': 'hello', 'id' : 10}]
+ Example: >vim
+ echo matchfuzzypos(['testing'], 'tsg')
+ <results in [["testing"], [[0, 2, 6]], [99]] >vim
+ echo matchfuzzypos(['clay', 'lacy'], 'la')
+ <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
+ echo [{'text': 'hello', 'id' : 10}]
\ ->matchfuzzypos('ll', {'key' : 'text'})
<results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
-
]=],
name = 'matchfuzzypos',
params = { { 'list', 'any' }, { 'str', 'any' }, { 'dict', 'any' } },
@@ -7110,16 +7107,16 @@ M.funcs = {
list is the matched string, same as what matchstr() would
return. Following items are submatches, like "\1", "\2", etc.
in |:substitute|. When an optional submatch didn't match an
- empty string is used. Example: >
+ empty string is used. Example: >vim
echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
<Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
When there is no match an empty list is returned.
You can pass in a List, but that is not very useful.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchlist('word')
-
+ <
]=],
name = 'matchlist',
params = { { 'expr', 'any' }, { 'pat', 'any' }, { 'start', 'any' }, { 'count', 'any' } },
@@ -7129,21 +7126,21 @@ M.funcs = {
args = { 2, 4 },
base = 1,
desc = [=[
- Same as |match()|, but return the matched string. Example: >
- :echo matchstr("testing", "ing")
+ Same as |match()|, but return the matched string. Example: >vim
+ echo matchstr("testing", "ing")
<results in "ing".
When there is no match "" is returned.
- The {start}, if given, has the same meaning as for |match()|. >
- :echo matchstr("testing", "ing", 2)
- <results in "ing". >
- :echo matchstr("testing", "ing", 5)
+ The {start}, if given, has the same meaning as for |match()|. >vim
+ echo matchstr("testing", "ing", 2)
+ <results in "ing". >vim
+ echo matchstr("testing", "ing", 5)
<result is "".
When {expr} is a |List| then the matching item is returned.
The type isn't changed, it's not necessarily a String.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchstr('word')
-
+ <
]=],
name = 'matchstr',
params = { { 'expr', 'any' }, { 'pat', 'any' }, { 'start', 'any' }, { 'count', 'any' } },
@@ -7154,23 +7151,23 @@ M.funcs = {
base = 1,
desc = [=[
Same as |matchstr()|, but return the matched string, the start
- position and the end position of the match. Example: >
- :echo matchstrpos("testing", "ing")
+ position and the end position of the match. Example: >vim
+ echo matchstrpos("testing", "ing")
<results in ["ing", 4, 7].
When there is no match ["", -1, -1] is returned.
- The {start}, if given, has the same meaning as for |match()|. >
- :echo matchstrpos("testing", "ing", 2)
- <results in ["ing", 4, 7]. >
- :echo matchstrpos("testing", "ing", 5)
+ The {start}, if given, has the same meaning as for |match()|. >vim
+ echo matchstrpos("testing", "ing", 2)
+ <results in ["ing", 4, 7]. >vim
+ echo matchstrpos("testing", "ing", 5)
<result is ["", -1, -1].
When {expr} is a |List| then the matching item, the index
of first item where {pat} matches, the start position and the
- end position of the match are returned. >
- :echo matchstrpos([1, '__x'], '\a')
+ end position of the match are returned. >vim
+ echo matchstrpos([1, '__x'], '\a')
<result is ["x", 1, 2, 3].
The type isn't changed, it's not necessarily a String.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->matchstrpos('word')
<
]=],
@@ -7182,7 +7179,7 @@ M.funcs = {
args = 1,
base = 1,
desc = [=[
- Return the maximum value of all items in {expr}. Example: >
+ Return the maximum value of all items in {expr}. Example: >vim
echo max([apples, pears, oranges])
<{expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -7191,7 +7188,7 @@ M.funcs = {
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->max()
<
]=],
@@ -7206,14 +7203,14 @@ M.funcs = {
by |:menu|, |:amenu|, …), including |hidden-menus|.
{path} matches a menu by name, or all menus if {path} is an
- empty string. Example: >
- :echo menu_get('File','')
- :echo menu_get('')
+ empty string. Example: >vim
+ echo menu_get('File','')
+ echo menu_get('')
<
{modes} is a string of zero or more modes (see |maparg()| or
|creating-menus| for the list of modes). "a" means "all".
- Example: >
+ Example: >vim
nnoremenu &Test.Test inormal
inoremenu Test.Test insert
vnoremenu Test.Test x
@@ -7246,7 +7243,6 @@ M.funcs = {
} ]
} ]
<
-
]=],
name = 'menu_get',
params = { { 'path', 'string' }, { 'modes', 'any' } },
@@ -7307,9 +7303,9 @@ M.funcs = {
Returns an empty dictionary if the menu item is not found.
- Examples: >
- :echo menu_info('Edit.Cut')
- :echo menu_info('File.Save', 'n')
+ Examples: >vim
+ echo menu_info('Edit.Cut')
+ echo menu_info('File.Save', 'n')
" Display the entire menu hierarchy in a buffer
func ShowMenu(name, pfx)
@@ -7325,7 +7321,7 @@ M.funcs = {
call ShowMenu(topmenu, '')
endfor
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMenuName()->menu_info('v')
<
]=],
@@ -7337,7 +7333,7 @@ M.funcs = {
args = 1,
base = 1,
desc = [=[
- Return the minimum value of all items in {expr}. Example: >
+ Return the minimum value of all items in {expr}. Example: >vim
echo min([apples, pears, oranges])
<{expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -7346,7 +7342,7 @@ M.funcs = {
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->min()
<
]=],
@@ -7367,19 +7363,19 @@ M.funcs = {
created as necessary.
If {flags} contains "D" then {name} is deleted at the end of
- the current function, as with: >
+ the current function, as with: >vim
defer delete({name}, 'd')
<
If {flags} contains "R" then {name} is deleted recursively at
- the end of the current function, as with: >
+ the end of the current function, as with: >vim
defer delete({name}, 'rf')
<Note that when {name} has more than one part and "p" is used
some directories may already exist. Only the first one that
is created and what it contains is scheduled to be deleted.
- E.g. when using: >
+ E.g. when using: >vim
call mkdir('subdir/tmp/autoload', 'pR')
<and "subdir" already exists then "subdir/tmp" will be
- scheduled for deletion, like with: >
+ scheduled for deletion, like with: >vim
defer delete('subdir/tmp', 'rf')
<
If {prot} is given it is used to set the protection bits of
@@ -7388,8 +7384,8 @@ M.funcs = {
unreadable for others.
{prot} is applied for all parts of {name}. Thus if you create
- /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >
- :call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
+ /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
+ call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
<This function is not available in the |sandbox|.
@@ -7400,7 +7396,7 @@ M.funcs = {
successful or FALSE if the directory creation failed or partly
failed.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->mkdir()
<
]=],
@@ -7463,9 +7459,9 @@ M.funcs = {
the leading character(s).
Also see |visualmode()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
DoFull()->mode()
-
+ <
]=],
name = 'mode',
params = {},
@@ -7476,9 +7472,9 @@ M.funcs = {
desc = [=[
Convert a list of Vimscript objects to msgpack. Returned value is a
|readfile()|-style list. When {type} contains "B", a |Blob| is
- returned instead. Example: >
+ returned instead. Example: >vim
call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
- <or, using a |Blob|: >
+ <or, using a |Blob|: >vim
call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
<
This will write the single 0x80 byte to a `fname.mpack` file
@@ -7491,7 +7487,6 @@ M.funcs = {
3. Dictionary keys are always dumped as STR strings.
4. Other strings and |Blob|s are always dumped as BIN strings.
5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
-
]=],
name = 'msgpackdump',
params = { { 'list', 'any' }, { 'type', 'any' } },
@@ -7502,7 +7497,7 @@ M.funcs = {
desc = [=[
Convert a |readfile()|-style list or a |Blob| to a list of
Vimscript objects.
- Example: >
+ Example: >vim
let fname = expand('~/.config/nvim/shada/main.shada')
let mpack = readfile(fname, 'b')
let shada_objects = msgpackparse(mpack)
@@ -7572,7 +7567,6 @@ M.funcs = {
ext |List| with two values: first is a signed integer
representing extension type. Second is
|readfile()|-style list of strings.
-
]=],
name = 'msgpackparse',
params = { { 'data', 'any' } },
@@ -7583,16 +7577,16 @@ M.funcs = {
base = 1,
desc = [=[
Return the line number of the first line at or below {lnum}
- that is not blank. Example: >
- if getline(nextnonblank(1)) =~ "Java"
+ that is not blank. Example: >vim
+ if getline(nextnonblank(1)) =~ "Java" | endif
<When {lnum} is invalid or there is no non-blank line at or
below it, zero is returned.
{lnum} is used like with |getline()|.
See also |prevnonblank()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->nextnonblank()
-
+ <
]=],
name = 'nextnonblank',
params = { { 'lnum', 'integer' } },
@@ -7603,19 +7597,20 @@ M.funcs = {
base = 1,
desc = [=[
Return a string with a single character, which has the number
- value {expr}. Examples: >
- nr2char(64) returns "@"
- nr2char(32) returns " "
- <Example for "utf-8": >
- nr2char(300) returns I with bow character
- <UTF-8 encoding is always used, {utf8} option has no effect,
+ value {expr}. Examples: >vim
+ echo nr2char(64) " returns '@'
+ echo nr2char(32) " returns ' '
+ <Example for "utf-8": >vim
+ echo nr2char(300) " returns I with bow character
+ <
+ UTF-8 encoding is always used, {utf8} option has no effect,
and exists only for backwards-compatibility.
Note that a NUL character in the file is specified with
nr2char(10), because NULs are represented with newline
characters. nr2char(0) is a real NUL and terminates the
string, thus results in an empty string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetNumber()->nr2char()
<
]=],
@@ -7650,10 +7645,10 @@ M.funcs = {
Bitwise OR on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see `and()` and `xor()`.
- Example: >
- :let bits = or(bits, 0x80)
- <Can also be used as a |method|: >
- :let bits = bits->or(0x80)
+ Example: >vim
+ let bits = or(bits, 0x80)
+ <Can also be used as a |method|: >vim
+ let bits = bits->or(0x80)
<Rationale: The reason this is a function and not using the "|"
character like many languages, is that Vi has always used "|"
@@ -7672,18 +7667,18 @@ M.funcs = {
result. The tail, the file name, is kept as-is. The other
components in the path are reduced to {len} letters in length.
If {len} is omitted or smaller than 1 then 1 is used (single
- letters). Leading '~' and '.' characters are kept. Examples: >
- :echo pathshorten('~/.config/nvim/autoload/file1.vim')
+ letters). Leading '~' and '.' characters are kept. Examples: >vim
+ echo pathshorten('~/.config/nvim/autoload/file1.vim')
< ~/.c/n/a/file1.vim ~
- >
- :echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
+ >vim
+ echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
< ~/.co/nv/au/file2.vim ~
It doesn't matter if the path exists or not.
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetDirectories()->pathshorten()
-
+ <
]=],
name = 'pathshorten',
params = { { 'path', 'string' }, { 'len', 'any' } },
@@ -7703,13 +7698,13 @@ M.funcs = {
Note: If you want an array or hash, {expr} must return a
reference to it.
- Example: >
- :echo perleval('[1 .. 4]')
+ Example: >vim
+ echo perleval('[1 .. 4]')
< [1, 2, 3, 4]
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->perleval()
-
+ <
]=],
name = 'perleval',
params = { { 'expr', 'any' } },
@@ -7722,17 +7717,17 @@ M.funcs = {
Return the power of {x} to the exponent {y} as a |Float|.
{x} and {y} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
- Examples: >
- :echo pow(3, 3)
- < 27.0 >
- :echo pow(2, 16)
- < 65536.0 >
- :echo pow(32, 0.20)
+ Examples: >vim
+ echo pow(3, 3)
+ < 27.0 >vim
+ echo pow(2, 16)
+ < 65536.0 >vim
+ echo pow(32, 0.20)
< 2.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->pow(3)
-
+ <
]=],
name = 'pow',
params = { { 'x', 'any' }, { 'y', 'any' } },
@@ -7743,16 +7738,16 @@ M.funcs = {
base = 1,
desc = [=[
Return the line number of the first line at or above {lnum}
- that is not blank. Example: >
+ that is not blank. Example: >vim
let ind = indent(prevnonblank(v:lnum - 1))
<When {lnum} is invalid or there is no non-blank line at or
above it, zero is returned.
{lnum} is used like with |getline()|.
Also see |nextnonblank()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetLnum()->prevnonblank()
-
+ <
]=],
name = 'prevnonblank',
params = { { 'lnum', 'integer' } },
@@ -7763,13 +7758,13 @@ M.funcs = {
base = 2,
desc = [=[
Return a String with {fmt}, where "%" items are replaced by
- the formatted form of their respective arguments. Example: >
- printf("%4d: E%d %.30s", lnum, errno, msg)
+ the formatted form of their respective arguments. Example: >vim
+ echo printf("%4d: E%d %.30s", lnum, errno, msg)
<May result in:
" 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
When used as a |method| the base is passed as the second
- argument: >
+ argument: >vim
Compute()->printf("result: %d")
<
You can use `call()` to pass the items as a list.
@@ -7869,8 +7864,8 @@ M.funcs = {
Number argument supplies the field width or precision. A
negative field width is treated as a left adjustment flag
followed by a positive field width; a negative precision is
- treated as though it were missing. Example: >
- :echo printf("%d: %.*s", nr, width, line)
+ treated as though it were missing. Example: >vim
+ echo printf("%d: %.*s", nr, width, line)
<This limits the length of the text used from "line" to
"width" bytes.
@@ -7925,7 +7920,7 @@ M.funcs = {
(out of range or dividing by zero) results in "inf"
or "-inf" with %f (INF or -INF with %F).
"0.0 / 0.0" results in "nan" with %f (NAN with %F).
- Example: >
+ Example: >vim
echo printf("%.2f", 12.115)
< 12.12
Note that roundoff depends on the system libraries.
@@ -7960,7 +7955,6 @@ M.funcs = {
The number of {exprN} arguments must exactly match the number
of "%" items. If there are not sufficient or too many
arguments an error is given. Up to 18 arguments can be used.
-
]=],
name = 'printf',
params = { { 'fmt', 'any' }, { 'expr1', 'any' } },
@@ -7976,9 +7970,9 @@ M.funcs = {
If the buffer doesn't exist or isn't a prompt buffer, an empty
string is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->prompt_getprompt()
-
+ <
]=],
name = 'prompt_getprompt',
params = { { 'buf', 'any' } },
@@ -8003,7 +7997,7 @@ M.funcs = {
The callback is invoked with one argument, which is the text
that was entered at the prompt. This can be an empty string
if the user only typed Enter.
- Example: >
+ Example: >vim
func s:TextEntered(text)
if a:text == 'exit' || a:text == 'quit'
stopinsert
@@ -8019,9 +8013,9 @@ M.funcs = {
endfunc
call prompt_setcallback(bufnr(), function('s:TextEntered'))
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetBuffer()->prompt_setcallback(callback)
-
+ <
]=],
name = 'prompt_setcallback',
params = { { 'buf', 'any' }, { 'expr', 'any' } },
@@ -8039,9 +8033,9 @@ M.funcs = {
mode. Without setting a callback Vim will exit Insert mode,
as in any buffer.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->prompt_setinterrupt(callback)
-
+ <
]=],
name = 'prompt_setinterrupt',
params = { { 'buf', 'any' }, { 'expr', 'any' } },
@@ -8054,12 +8048,12 @@ M.funcs = {
Set prompt for buffer {buf} to {text}. You most likely want
{text} to end in a space.
The result is only visible if {buf} has 'buftype' set to
- "prompt". Example: >
+ "prompt". Example: >vim
call prompt_setprompt(bufnr(''), 'command: ')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBuffer()->prompt_setprompt('command: ')
-
+ <
]=],
name = 'prompt_setprompt',
params = { { 'buf', 'any' }, { 'text', 'any' } },
@@ -8078,7 +8072,6 @@ M.funcs = {
scrollbar |TRUE| if scrollbar is visible
The values are the same as in |v:event| during |CompleteChanged|.
-
]=],
name = 'pum_getpos',
params = {},
@@ -8090,7 +8083,6 @@ M.funcs = {
otherwise. See |ins-completion-menu|.
This can be used to avoid some things that would remove the
popup menu.
-
]=],
name = 'pumvisible',
params = {},
@@ -8109,7 +8101,7 @@ M.funcs = {
Dictionaries are represented as Vim |Dictionary| type with
keys converted to strings.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->py3eval()
<
]=],
@@ -8129,9 +8121,9 @@ M.funcs = {
Dictionaries are represented as Vim |Dictionary| type,
non-string keys result in error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->pyeval()
-
+ <
]=],
func = 'f_py3eval',
name = 'pyeval',
@@ -8148,7 +8140,7 @@ M.funcs = {
Uses Python 2 or 3, see |python_x| and 'pyxversion'.
See also: |pyeval()|, |py3eval()|
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetExpr()->pyxeval()
<
]=],
@@ -8169,13 +8161,13 @@ M.funcs = {
and updated.
Returns -1 if {expr} is invalid.
- Examples: >
- :echo rand()
- :let seed = srand()
- :echo rand(seed)
- :echo rand(seed) % 16 " random number 0 - 15
+ Examples: >vim
+ echo rand()
+ let seed = srand()
+ echo rand(seed)
+ echo rand(seed) % 16 " random number 0 - 15
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
seed->rand()
<
]=],
@@ -8196,18 +8188,17 @@ M.funcs = {
When the maximum is one before the start the result is an
empty list. When the maximum is more than one before the
start this is an error.
- Examples: >
- range(4) " [0, 1, 2, 3]
- range(2, 4) " [2, 3, 4]
- range(2, 9, 3) " [2, 5, 8]
- range(2, -2, -1) " [2, 1, 0, -1, -2]
- range(0) " []
- range(2, 0) " error!
- <
- Can also be used as a |method|: >
+ Examples: >vim
+ echo range(4) " [0, 1, 2, 3]
+ echo range(2, 4) " [2, 3, 4]
+ echo range(2, 9, 3) " [2, 5, 8]
+ echo range(2, -2, -1) " [2, 1, 0, -1, -2]
+ echo range(0) " []
+ echo range(2, 0) " error!
+ <
+ Can also be used as a |method|: >vim
GetExpr()->range()
<
-
]=],
name = 'range',
params = { { 'expr', 'any' }, { 'max', 'any' }, { 'stride', 'any' } },
@@ -8221,18 +8212,18 @@ M.funcs = {
Read file {fname} in binary mode and return a |Blob|.
If {offset} is specified, read the file from the specified
offset. If it is a negative value, it is used as an offset
- from the end of the file. E.g., to read the last 12 bytes: >
- readblob('file.bin', -12)
+ from the end of the file. E.g., to read the last 12 bytes: >vim
+ echo readblob('file.bin', -12)
<If {size} is specified, only the specified size will be read.
- E.g. to read the first 100 bytes of a file: >
- readblob('file.bin', 0, 100)
+ E.g. to read the first 100 bytes of a file: >vim
+ echo readblob('file.bin', 0, 100)
<If {size} is -1 or omitted, the whole data starting from
{offset} will be read.
This can be also used to read the data from a character device
on Unix when {size} is explicitly set. Only if the device
supports seeking {offset} can be used. Otherwise it should be
- zero. E.g. to read 10 bytes from a serial console: >
- readblob('/dev/ttyS0', 0, 10)
+ zero. E.g. to read 10 bytes from a serial console: >vim
+ echo readblob('/dev/ttyS0', 0, 10)
<When the file can't be opened an error message is given and
the result is an empty |Blob|.
When the offset is beyond the end of the file the result is an
@@ -8263,12 +8254,12 @@ M.funcs = {
to the list.
Each time {expr} is evaluated |v:val| is set to the entry name.
When {expr} is a function the name is passed as the argument.
- For example, to get a list of files ending in ".txt": >
- readdir(dirname, {n -> n =~ '.txt$'})
- <To skip hidden and backup files: >
- readdir(dirname, {n -> n !~ '^\.\|\~$'})
+ For example, to get a list of files ending in ".txt": >vim
+ echo readdir(dirname, {n -> n =~ '.txt$'})
+ <To skip hidden and backup files: >vim
+ echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
- <If you want to get a directory tree: >
+ <If you want to get a directory tree: >vim
function! s:tree(dir)
return {a:dir : map(readdir(a:dir),
\ {_, x -> isdirectory(x) ?
@@ -8278,7 +8269,7 @@ M.funcs = {
<
Returns an empty List on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetDirName()->readdir()
<
]=],
@@ -8305,10 +8296,10 @@ M.funcs = {
- Any UTF-8 byte order mark is removed from the text.
When {max} is given this specifies the maximum number of lines
to be read. Useful if you only want to check the first ten
- lines of a file: >
- :for line in readfile(fname, '', 10)
- : if line =~ 'Date' | echo line | endif
- :endfor
+ lines of a file: >vim
+ for line in readfile(fname, '', 10)
+ if line =~ 'Date' | echo line | endif
+ endfor
<When {max} is negative -{max} lines from the end of the file
are returned, or as many as there are.
When {max} is zero the result is an empty list.
@@ -8322,7 +8313,7 @@ M.funcs = {
the result is an empty list.
Also see |writefile()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFileName()->readfile()
<
]=],
@@ -8345,14 +8336,14 @@ M.funcs = {
item. If {initial} is not given and {object} is empty no
result can be computed, an E998 error is given.
- Examples: >
+ Examples: >vim
echo reduce([1, 3, 5], { acc, val -> acc + val })
echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
echo reduce(0z1122, { acc, val -> 2 * acc + val })
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
echo mylist->reduce({ acc, val -> acc + val }, 0)
-
+ <
]=],
name = 'reduce',
params = { { 'object', 'any' }, { 'func', 'any' }, { 'initial', 'any' } },
@@ -8363,7 +8354,6 @@ M.funcs = {
Returns the single letter name of the register being executed.
Returns an empty string when no register is being executed.
See |@|.
-
]=],
name = 'reg_executing',
params = {},
@@ -8374,7 +8364,6 @@ M.funcs = {
Returns the single letter name of the last recorded register.
Returns an empty string when nothing was recorded yet.
See |q| and |Q|.
-
]=],
name = 'reg_recorded',
params = {},
@@ -8384,7 +8373,6 @@ M.funcs = {
desc = [=[
Returns the single letter name of the register being recorded.
Returns an empty string when not recording. See |q|.
-
]=],
name = 'reg_recording',
params = {},
@@ -8427,11 +8415,10 @@ M.funcs = {
The {start} and {end} arguments must be values returned by
reltime(). Returns zero on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetStart()->reltime()
<
Note: |localtime()| returns the current (non-relative) time.
-
]=],
fast = true,
name = 'reltime',
@@ -8452,9 +8439,9 @@ M.funcs = {
Also see |profiling|.
If there is an error an empty string is returned
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
reltime(start)->reltimefloat()
-
+ <
]=],
fast = true,
name = 'reltimefloat',
@@ -8467,19 +8454,19 @@ M.funcs = {
desc = [=[
Return a String that represents the time value of {time}.
This is the number of seconds, a dot and the number of
- microseconds. Example: >
+ microseconds. Example: >vim
let start = reltime()
call MyFunction()
echo reltimestr(reltime(start))
<Note that overhead for the commands will be added to the time.
Leading spaces are used to make the string align nicely. You
- can use split() to remove it. >
+ can use split() to remove it. >vim
echo split(reltimestr(reltime(start)))[0]
<Also see |profiling|.
If there is an error an empty string is returned
- Can also be used as a |method|: >
- reltime(start)->reltimestr()
+ Can also be used as a |method|: >vim
+ echo reltime(start)->reltimestr()
<
]=],
fast = true,
@@ -8506,15 +8493,15 @@ M.funcs = {
points to an item before {idx} this is an error.
See |list-index| for possible values of {idx} and {end}.
Returns zero on error.
- Example: >
- :echo "last item: " .. remove(mylist, -1)
- :call remove(mylist, 0, 9)
+ Example: >vim
+ echo "last item: " .. remove(mylist, -1)
+ call remove(mylist, 0, 9)
<
Use |delete()| to remove a file.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->remove(idx)
-
+ <
]=],
name = 'remove',
params = { { 'list', 'any' }, { 'idx', 'integer' }, { 'end', 'any' } },
@@ -8538,10 +8525,10 @@ M.funcs = {
byte as {end} a |Blob| with one byte is returned. When {end}
points to a byte before {idx} this is an error.
Returns zero on error.
- Example: >
- :echo "last byte: " .. remove(myblob, -1)
- :call remove(mylist, 0, 9)
-
+ Example: >vim
+ echo "last byte: " .. remove(myblob, -1)
+ call remove(mylist, 0, 9)
+ <
]=],
name = 'remove',
params = { { 'blob', 'any' }, { 'idx', 'integer' }, { 'end', 'any' } },
@@ -8552,11 +8539,10 @@ M.funcs = {
base = 1,
desc = [=[
Remove the entry from {dict} with key {key} and return it.
- Example: >
- :echo "removed " .. remove(dict, "one")
+ Example: >vim
+ echo "removed " .. remove(dict, "one")
<If there is no {key} in {dict} this is an error.
Returns zero on error.
-
]=],
name = 'remove',
params = { { 'dict', 'any' }, { 'key', 'any' } },
@@ -8573,9 +8559,9 @@ M.funcs = {
NOTE: If {to} exists it is overwritten without warning.
This function is not available in the |sandbox|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetOldName()->rename(newname)
-
+ <
]=],
name = 'rename',
params = { { 'from', 'any' }, { 'to', 'any' } },
@@ -8586,15 +8572,15 @@ M.funcs = {
base = 1,
desc = [=[
Repeat {expr} {count} times and return the concatenated
- result. Example: >
- :let separator = repeat('-', 80)
+ result. Example: >vim
+ let separator = repeat('-', 80)
<When {count} is zero or negative the result is empty.
When {expr} is a |List| or a |Blob| the result is {expr}
- concatenated {count} times. Example: >
- :let longlist = repeat(['a', 'b'], 3)
+ concatenated {count} times. Example: >vim
+ let longlist = repeat(['a', 'b'], 3)
<Results in ['a', 'b', 'a', 'b', 'a', 'b'].
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->repeat(count)
<
]=],
@@ -8620,7 +8606,7 @@ M.funcs = {
current directory (provided the result is still a relative
path name) and also keeps a trailing path separator.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->resolve()
<
]=],
@@ -8637,11 +8623,11 @@ M.funcs = {
{object} can be a |List| or a |Blob|.
Returns {object}.
Returns zero if {object} is not a List or a Blob.
- If you want an object to remain unmodified make a copy first: >
- :let revlist = reverse(copy(mylist))
- <Can also be used as a |method|: >
+ If you want an object to remain unmodified make a copy first: >vim
+ let revlist = reverse(copy(mylist))
+ <Can also be used as a |method|: >vim
mylist->reverse()
-
+ <
]=],
name = 'reverse',
params = { { 'object', 'any' } },
@@ -8656,17 +8642,17 @@ M.funcs = {
values, then use the larger one (away from zero).
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo round(0.456)
- < 0.0 >
+ < 0.0 >vim
echo round(4.5)
- < 5.0 >
+ < 5.0 >vim
echo round(-4.5)
< -5.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->round()
-
+ <
]=],
float_func = 'round',
name = 'round',
@@ -8678,9 +8664,9 @@ M.funcs = {
desc = [=[
Sends {event} to {channel} via |RPC| and returns immediately.
If {channel} is 0, the event is broadcast to all channels.
- Example: >
- :au VimLeave call rpcnotify(0, "leaving")
-
+ Example: >vim
+ au VimLeave call rpcnotify(0, "leaving")
+ <
]=],
name = 'rpcnotify',
params = { { 'channel', 'any' }, { 'event', 'any' }, { 'args', 'any' } },
@@ -8691,9 +8677,9 @@ M.funcs = {
desc = [=[
Sends a request to {channel} to invoke {method} via
|RPC| and blocks until a response is received.
- Example: >
- :let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
-
+ Example: >vim
+ let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
+ <
]=],
name = 'rpcrequest',
params = { { 'channel', 'any' }, { 'method', 'any' }, { 'args', 'any' } },
@@ -8702,11 +8688,11 @@ M.funcs = {
rpcstart = {
args = { 1, 2 },
desc = [=[
- Deprecated. Replace >
- :let id = rpcstart('prog', ['arg1', 'arg2'])
- <with >
- :let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
-
+ Deprecated. Replace >vim
+ let id = rpcstart('prog', ['arg1', 'arg2'])
+ <with >vim
+ let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
+ <
]=],
name = 'rpcstart',
params = { { 'prog', 'any' }, { 'argv', 'any' } },
@@ -8737,9 +8723,9 @@ M.funcs = {
Other objects are represented as strings resulted from their
"Object#to_s" method.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRubyExpr()->rubyeval()
-
+ <
]=],
name = 'rubyeval',
params = { { 'expr', 'any' } },
@@ -8754,9 +8740,9 @@ M.funcs = {
attribute at other positions.
Returns -1 when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenattr(col)
-
+ <
]=],
name = 'screenattr',
params = { { 'row', 'any' }, { 'col', 'integer' } },
@@ -8775,9 +8761,9 @@ M.funcs = {
This is mainly to be used for testing.
Returns -1 when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenchar(col)
-
+ <
]=],
name = 'screenchar',
params = { { 'row', 'any' }, { 'col', 'integer' } },
@@ -8793,9 +8779,9 @@ M.funcs = {
This is mainly to be used for testing.
Returns an empty List when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenchars(col)
-
+ <
]=],
name = 'screenchars',
params = { { 'row', 'any' }, { 'col', 'integer' } },
@@ -8811,7 +8797,7 @@ M.funcs = {
in a command (e.g. ":echo screencol()") it will return the
column inside the command line, which is 1 when the command is
executed. To get the cursor position in the file use one of
- the following mappings: >
+ the following mappings: >vim
nnoremap <expr> GG ":echom " .. screencol() .. "\n"
nnoremap <silent> GG :echom screencol()<CR>
noremap GG <Cmd>echom screencol()<Cr>
@@ -8848,9 +8834,9 @@ M.funcs = {
first character is returned, {col} is not used.
Returns an empty Dict if {winid} is invalid.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->screenpos(lnum, col)
-
+ <
]=],
name = 'screenpos',
params = { { 'winid', 'integer' }, { 'lnum', 'integer' }, { 'col', 'integer' } },
@@ -8864,7 +8850,6 @@ M.funcs = {
Alternatively you can use |winline()|.
Note: Same restrictions as with |screencol()|.
-
]=],
name = 'screenrow',
params = {},
@@ -8881,7 +8866,7 @@ M.funcs = {
This is mainly to be used for testing.
Returns an empty String when row or col is out of range.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetRow()->screenstring(col)
<
]=],
@@ -8933,7 +8918,7 @@ M.funcs = {
When the {stopline} argument is given then the search stops
after searching this line. This is useful to restrict the
- search to a range of lines. Examples: >
+ search to a range of lines. Examples: >vim
let match = search('(', 'b', line("w0"))
let end = search('END', '', line("w$"))
<When {stopline} is used and it is not zero this also implies
@@ -8964,24 +8949,24 @@ M.funcs = {
The cursor will be positioned at the match, unless the 'n'
flag is used.
- Example (goes over all files in the argument list): >
- :let n = 1
- :while n <= argc() " loop over all files in arglist
- : exe "argument " .. n
- : " start at the last char in the file and wrap for the
- : " first search to find match at start of file
- : normal G$
- : let flags = "w"
- : while search("foo", flags) > 0
- : s/foo/bar/g
- : let flags = "W"
- : endwhile
- : update " write the file if modified
- : let n = n + 1
- :endwhile
- <
- Example for using some flags: >
- :echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
+ Example (goes over all files in the argument list): >vim
+ let n = 1
+ while n <= argc() " loop over all files in arglist
+ exe "argument " .. n
+ " start at the last char in the file and wrap for the
+ " first search to find match at start of file
+ normal G$
+ let flags = "w"
+ while search("foo", flags) > 0
+ s/foo/bar/g
+ let flags = "W"
+ endwhile
+ update " write the file if modified
+ let n = n + 1
+ endwhile
+ <
+ Example for using some flags: >vim
+ echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
<This will search for the keywords "if", "else", and "endif"
under or after the cursor. Because of the 'p' flag, it
returns 1, 2, or 3 depending on which keyword is found, or 0
@@ -8993,9 +8978,9 @@ M.funcs = {
without the 'e' flag if the cursor is on the "f" of "if".
The 'n' flag tells the function not to move the cursor.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPattern()->search()
-
+ <
]=],
name = 'search',
params = {
@@ -9035,7 +9020,7 @@ M.funcs = {
this function with `recompute: 0` . This sometimes returns
wrong information because |n| and |N|'s maximum count is 99.
If it exceeded 99 the result must be max count + 1 (100). If
- you want to get correct information, specify `recompute: 1`: >
+ you want to get correct information, specify `recompute: 1`: >vim
" result == maxcount + 1 (100) when many matches
let result = searchcount(#{recompute: 0})
@@ -9044,7 +9029,7 @@ M.funcs = {
" to 1)
let result = searchcount()
<
- The function is useful to add the count to 'statusline': >
+ The function is useful to add the count to 'statusline': >vim
function! LastSearchCount() abort
let result = searchcount(#{recompute: 0})
if empty(result)
@@ -9073,7 +9058,7 @@ M.funcs = {
" \ '%{v:hlsearch ? LastSearchCount() : ""}'
<
You can also update the search count, which can be useful in a
- |CursorMoved| or |CursorMovedI| autocommand: >
+ |CursorMoved| or |CursorMovedI| autocommand: >vim
autocmd CursorMoved,CursorMovedI *
\ let s:searchcount_timer = timer_start(
@@ -9087,7 +9072,7 @@ M.funcs = {
endfunction
<
This can also be used to count matched texts with specified
- pattern in the current buffer using "pattern": >
+ pattern in the current buffer using "pattern": >vim
" Count '\<foo\>' in this buffer
" (Note that it also updates search count)
@@ -9111,7 +9096,7 @@ M.funcs = {
and different with |@/|.
this works as same as the
below command is executed
- before calling this function >
+ before calling this function >vim
let @/ = pattern
< (default: |@/|)
timeout |Number| 0 or negative number is no
@@ -9131,7 +9116,7 @@ M.funcs = {
value. see |cursor()|, |getpos()|
(default: cursor's position)
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSearchOpts()->searchcount()
<
]=],
@@ -9155,12 +9140,12 @@ M.funcs = {
Moves the cursor to the found match.
Returns zero for success, non-zero for failure.
- Example: >
+ Example: >vim
if searchdecl('myvar') == 0
echo getline('.')
endif
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->searchdecl()
<
]=],
@@ -9185,8 +9170,8 @@ M.funcs = {
must not contain \( \) pairs. Use of \%( \) is allowed. When
{middle} is not empty, it is found when searching from either
direction, but only when not in a nested start-end pair. A
- typical use is: >
- searchpair('\<if\>', '\<else\>', '\<endif\>')
+ typical use is: >vim
+ echo searchpair('\<if\>', '\<else\>', '\<endif\>')
<By leaving {middle} empty the "else" is skipped.
{flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
@@ -9216,7 +9201,7 @@ M.funcs = {
The search starts exactly at the cursor. A match with
{start}, {middle} or {end} at the next character, in the
- direction of searching, is the first one found. Example: >
+ direction of searching, is the first one found. Example: >vim
if 1
if 2
endif 2
@@ -9232,9 +9217,9 @@ M.funcs = {
that when the cursor is inside a match with the end it finds
the matching start.
- Example, to find the "endif" command in a Vim script: >
+ Example, to find the "endif" command in a Vim script: >vim
- :echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
+ echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
\ 'getline(".") =~ "^\\s*\""')
<The cursor must be at or after the "if" for which a match is
@@ -9243,15 +9228,15 @@ M.funcs = {
catches comments at the start of a line, not after a command.
Also, a word "en" or "if" halfway through a line is considered
a match.
- Another example, to search for the matching "{" of a "}": >
+ Another example, to search for the matching "{" of a "}": >vim
- :echo searchpair('{', '', '}', 'bW')
+ echo searchpair('{', '', '}', 'bW')
<This works when the cursor is at or before the "}" for which a
match is to be found. To reject matches that syntax
- highlighting recognized as strings: >
+ highlighting recognized as strings: >vim
- :echo searchpair('{', '', '}', 'bW',
+ echo searchpair('{', '', '}', 'bW',
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
<
]=],
@@ -9266,9 +9251,9 @@ M.funcs = {
column position of the match. The first element of the |List|
is the line number and the second element is the byte index of
the column position of the match. If no match is found,
- returns [0, 0]. >
+ returns [0, 0]. >vim
- :let [lnum,col] = searchpairpos('{', '', '}', 'n')
+ let [lnum,col] = searchpairpos('{', '', '}', 'n')
<
See |match-parens| for a bigger and more useful example.
]=],
@@ -9285,18 +9270,18 @@ M.funcs = {
is the line number and the second element is the byte index of
the column position of the match. If no match is found,
returns [0, 0].
- Example: >
- :let [lnum, col] = searchpos('mypattern', 'n')
+ Example: >vim
+ let [lnum, col] = searchpos('mypattern', 'n')
<When the 'p' flag is given then there is an extra item with
- the sub-pattern match number |search()-sub-match|. Example: >
- :let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
+ the sub-pattern match number |search()-sub-match|. Example: >vim
+ let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
<In this example "submatch" is 2 when a lowercase letter is
found |/\l|, 3 when an uppercase letter is found |/\u|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPattern()->searchpos()
-
+ <
]=],
name = 'searchpos',
params = {
@@ -9312,9 +9297,9 @@ M.funcs = {
desc = [=[
Returns a list of server addresses, or empty if all servers
were stopped. |serverstart()| |serverstop()|
- Example: >
- :echo serverlist()
-
+ Example: >vim
+ echo serverlist()
+ <
]=],
name = 'serverlist',
params = {},
@@ -9335,25 +9320,26 @@ M.funcs = {
assigns a random port).
- Else {address} is the path to a named pipe (except on Windows).
- If {address} has no slashes ("/") it is treated as the
- "name" part of a generated path in this format: >
+ "name" part of a generated path in this format: >vim
stdpath("run").."/{name}.{pid}.{counter}"
- < - If {address} is omitted the name is "nvim". >
- :echo serverstart()
+ < - If {address} is omitted the name is "nvim". >vim
+ echo serverstart()
+ < >
=> /tmp/nvim.bram/oknANW/nvim.15430.5
-
- <Example bash command to list all Nvim servers: >
+ <
+ Example bash command to list all Nvim servers: >bash
ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
- <Example named pipe: >
+ <Example named pipe: >vim
if has('win32')
echo serverstart('\\.\pipe\nvim-pipe-1234')
else
echo serverstart('nvim.sock')
endif
<
- Example TCP/IP address: >
+ Example TCP/IP address: >vim
echo serverstart('::1:12345')
-
+ <
]=],
name = 'serverstart',
params = { { 'address', 'any' } },
@@ -9366,7 +9352,6 @@ M.funcs = {
Returns TRUE if {address} is valid, else FALSE.
If |v:servername| is stopped it is set to the next available
address in |serverlist()|.
-
]=],
name = 'serverstop',
params = { { 'address', 'any' } },
@@ -9400,9 +9385,9 @@ M.funcs = {
error message is given.
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetText()->setbufline(buf, lnum)
-
+ <
]=],
name = 'setbufline',
params = { { 'buf', 'any' }, { 'lnum', 'integer' }, { 'text', 'any' } },
@@ -9420,13 +9405,13 @@ M.funcs = {
For the use of {buf}, see |bufname()| above.
The {varname} argument is a string.
Note that the variable name without "b:" must be used.
- Examples: >
- :call setbufvar(1, "&mod", 1)
- :call setbufvar("todo", "myvar", "foobar")
+ Examples: >vim
+ call setbufvar(1, "&mod", 1)
+ call setbufvar("todo", "myvar", "foobar")
<This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->setbufvar(buf, varname)
<
]=],
@@ -9441,7 +9426,7 @@ M.funcs = {
Specify overrides for cell widths of character ranges. This
tells Vim how wide characters are when displayed in the
terminal, counted in screen cells. The values override
- 'ambiwidth'. Example: >
+ 'ambiwidth'. Example: >vim
call setcellwidths([
\ [0x111, 0x111, 1],
\ [0x2194, 0x2199, 2],
@@ -9462,7 +9447,7 @@ M.funcs = {
If the new value causes 'fillchars' or 'listchars' to become
invalid it is rejected and an error is given.
- To clear the overrides pass an empty {list}: >
+ To clear the overrides pass an empty {list}: >vim
call setcellwidths([])
<You can use the script $VIMRUNTIME/tools/emoji_list.vim to see
@@ -9483,15 +9468,15 @@ M.funcs = {
character index instead of the byte index in the line.
Example:
- With the text "μ—¬λ³΄μ„Έμš”" in line 8: >
+ With the text "μ—¬λ³΄μ„Έμš”" in line 8: >vim
call setcharpos('.', [0, 8, 4, 0])
- <positions the cursor on the fourth character 'μš”'. >
+ <positions the cursor on the fourth character 'μš”'. >vim
call setpos('.', [0, 8, 4, 0])
<positions the cursor on the second character '보'.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPosition()->setcharpos('.')
-
+ <
]=],
name = 'setcharpos',
params = { { 'expr', 'any' }, { 'list', 'any' } },
@@ -9514,15 +9499,15 @@ M.funcs = {
character search
This can be useful to save/restore a user's character search
- from a script: >
- :let prevsearch = getcharsearch()
- :" Perform a command which clobbers user's search
- :call setcharsearch(prevsearch)
+ from a script: >vim
+ let prevsearch = getcharsearch()
+ " Perform a command which clobbers user's search
+ call setcharsearch(prevsearch)
<Also see |getcharsearch()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
SavedSearch()->setcharsearch()
-
+ <
]=],
name = 'setcharsearch',
params = { { 'dict', 'any' } },
@@ -9538,9 +9523,9 @@ M.funcs = {
Returns 0 when successful, 1 when not editing the command
line.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->setcmdline()
-
+ <
]=],
name = 'setcmdline',
params = { { 'str', 'any' }, { 'pos', 'any' } },
@@ -9564,9 +9549,9 @@ M.funcs = {
Returns 0 when successful, 1 when not editing the command
line.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPos()->setcmdpos()
-
+ <
]=],
name = 'setcmdpos',
params = { { 'pos', 'any' } },
@@ -9587,15 +9572,15 @@ M.funcs = {
character index instead of the byte index in the line.
Example:
- With the text "μ—¬λ³΄μ„Έμš”" in line 4: >
+ With the text "μ—¬λ³΄μ„Έμš”" in line 4: >vim
call setcursorcharpos(4, 3)
- <positions the cursor on the third character 'μ„Έ'. >
+ <positions the cursor on the third character 'μ„Έ'. >vim
call cursor(4, 3)
<positions the cursor on the first character 'μ—¬'.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCursorPos()->setcursorcharpos()
-
+ <
]=],
name = 'setcursorcharpos',
params = { { 'list', 'any' } },
@@ -9605,14 +9590,14 @@ M.funcs = {
args = 2,
base = 2,
desc = [=[
- Set environment variable {name} to {val}. Example: >
+ Set environment variable {name} to {val}. Example: >vim
call setenv('HOME', '/home/myhome')
<When {val} is |v:null| the environment variable is deleted.
See also |expr-env|.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetPath()->setenv('PATH')
<
]=],
@@ -9639,11 +9624,10 @@ M.funcs = {
Returns non-zero for success, zero for failure.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->setfperm(mode)
<
To read permissions see |getfperm()|.
-
]=],
name = 'setfperm',
params = { { 'fname', 'integer' }, { 'mode', 'string' } },
@@ -9666,23 +9650,23 @@ M.funcs = {
If this succeeds, FALSE is returned. If this fails (most likely
because {lnum} is invalid) TRUE is returned.
- Example: >
- :call setline(5, strftime("%c"))
+ Example: >vim
+ call setline(5, strftime("%c"))
<When {text} is a |List| then line {lnum} and following lines
- will be set to the items in the list. Example: >
- :call setline(5, ['aaa', 'bbb', 'ccc'])
- <This is equivalent to: >
- :for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
- : call setline(n, l)
- :endfor
+ will be set to the items in the list. Example: >vim
+ call setline(5, ['aaa', 'bbb', 'ccc'])
+ <This is equivalent to: >vim
+ for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
+ call setline(n, l)
+ endfor
<Note: The '[ and '] marks are not set.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetText()->setline(lnum)
-
+ <
]=],
name = 'setline',
params = { { 'lnum', 'integer' }, { 'text', 'any' } },
@@ -9708,9 +9692,9 @@ M.funcs = {
for the list of supported keys in {what}.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetLoclist()->setloclist(winnr)
-
+ <
]=],
name = 'setloclist',
params = { { 'nr', 'integer' }, { 'list', 'any' }, { 'action', 'any' }, { 'what', 'any' } },
@@ -9727,7 +9711,7 @@ M.funcs = {
If {win} is specified, use the window with this number or
window ID instead of the current window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMatches()->setmatches()
<
]=],
@@ -9787,9 +9771,9 @@ M.funcs = {
also set the preferred column. Also see the "curswant" key in
|winrestview()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetPosition()->setpos('.')
-
+ <
]=],
name = 'setpos',
params = { { 'expr', 'any' }, { 'list', 'any' } },
@@ -9851,8 +9835,8 @@ M.funcs = {
'r' The items from the current quickfix list are replaced
with the items from {list}. This can also be used to
- clear the list: >
- :call setqflist([], 'r')
+ clear the list: >vim
+ call setqflist([], 'r')
<
'f' All the quickfix lists in the quickfix stack are
freed.
@@ -9898,10 +9882,10 @@ M.funcs = {
list is modified, "id" should be used instead of "nr" to
specify the list.
- Examples (See also |setqflist-examples|): >
- :call setqflist([], 'r', {'title': 'My search'})
- :call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
- :call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
+ Examples (See also |setqflist-examples|): >vim
+ call setqflist([], 'r', {'title': 'My search'})
+ call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
+ call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
<
Returns zero for success, -1 for failure.
@@ -9910,7 +9894,7 @@ M.funcs = {
`:cc 1` to jump to the first position.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetErrorlist()->setqflist()
<
]=],
@@ -9953,34 +9937,34 @@ M.funcs = {
set search and expression registers. Lists containing no
items act like empty strings.
- Examples: >
- :call setreg(v:register, @*)
- :call setreg('*', @%, 'ac')
- :call setreg('a', "1\n2\n3", 'b5')
- :call setreg('"', { 'points_to': 'a'})
+ Examples: >vim
+ call setreg(v:register, @*)
+ call setreg('*', @%, 'ac')
+ call setreg('a', "1\n2\n3", 'b5')
+ call setreg('"', { 'points_to': 'a'})
<This example shows using the functions to save and restore a
- register: >
- :let var_a = getreginfo()
- :call setreg('a', var_a)
- <or: >
- :let var_a = getreg('a', 1, 1)
- :let var_amode = getregtype('a')
- ....
- :call setreg('a', var_a, var_amode)
+ register: >vim
+ let var_a = getreginfo()
+ call setreg('a', var_a)
+ <or: >vim
+ let var_a = getreg('a', 1, 1)
+ let var_amode = getregtype('a')
+ " ....
+ call setreg('a', var_a, var_amode)
<Note: you may not reliably restore register value
without using the third argument to |getreg()| as without it
newlines are represented as newlines AND Nul bytes are
represented as newlines as well, see |NL-used-for-Nul|.
You can also change the type of a register by appending
- nothing: >
- :call setreg('a', '', 'al')
+ nothing: >vim
+ call setreg('a', '', 'al')
<Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetText()->setreg('a')
-
+ <
]=],
name = 'setreg',
params = { { 'regname', 'string' }, { 'value', 'any' }, { 'options', 'table' } },
@@ -9998,9 +9982,9 @@ M.funcs = {
This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->settabvar(tab, name)
-
+ <
]=],
name = 'settabvar',
params = { { 'tabnr', 'integer' }, { 'varname', 'string' }, { 'val', 'any' } },
@@ -10020,15 +10004,15 @@ M.funcs = {
doesn't work for a global or local buffer variable.
For a local buffer option the global value is unchanged.
Note that the variable name without "w:" must be used.
- Examples: >
- :call settabwinvar(1, 1, "&list", 0)
- :call settabwinvar(3, 2, "myvar", "foobar")
+ Examples: >vim
+ call settabwinvar(1, 1, "&list", 0)
+ call settabwinvar(3, 2, "myvar", "foobar")
<This function is not available in the |sandbox|.
Can also be used as a |method|, the base is passed as the
- fourth argument: >
+ fourth argument: >vim
GetValue()->settabwinvar(tab, winnr, name)
-
+ <
]=],
name = 'settabwinvar',
params = {
@@ -10066,19 +10050,19 @@ M.funcs = {
Returns zero for success, -1 for failure.
Examples (for more examples see |tagstack-examples|):
- Empty the tag stack of window 3: >
+ Empty the tag stack of window 3: >vim
call settagstack(3, {'items' : []})
- < Save and restore the tag stack: >
+ < Save and restore the tag stack: >vim
let stack = gettagstack(1003)
" do something else
call settagstack(1003, stack)
unlet stack
<
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetStack()->settagstack(winnr)
-
+ <
]=],
name = 'settagstack',
params = { { 'nr', 'integer' }, { 'dict', 'any' }, { 'action', 'any' } },
@@ -10089,14 +10073,14 @@ M.funcs = {
base = 3,
desc = [=[
Like |settabwinvar()| for the current tab page.
- Examples: >
- :call setwinvar(1, "&list", 0)
- :call setwinvar(2, "myvar", "foobar")
+ Examples: >vim
+ call setwinvar(1, "&list", 0)
+ call setwinvar(2, "myvar", "foobar")
<Can also be used as a |method|, the base is passed as the
- third argument: >
+ third argument: >vim
GetValue()->setwinvar(winnr, name)
-
+ <
]=],
name = 'setwinvar',
params = { { 'nr', 'integer' }, { 'varname', 'string' }, { 'val', 'any' } },
@@ -10109,9 +10093,9 @@ M.funcs = {
Returns a String with 64 hex characters, which is the SHA256
checksum of {string}.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->sha256()
-
+ <
]=],
name = 'sha256',
params = { { 'string', 'string' } },
@@ -10144,16 +10128,16 @@ M.funcs = {
be escaped because in fish it is used as an escape character
inside single quotes.
- Example of use with a |:!| command: >
- :exe '!dir ' .. shellescape(expand('<cfile>'), 1)
+ Example of use with a |:!| command: >vim
+ exe '!dir ' .. shellescape(expand('<cfile>'), 1)
<This results in a directory listing for the file under the
- cursor. Example of use with |system()|: >
- :call system("chmod +w -- " .. shellescape(expand("%")))
+ cursor. Example of use with |system()|: >vim
+ call system("chmod +w -- " .. shellescape(expand("%")))
<See also |::S|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetCommand()->shellescape()
-
+ <
]=],
name = 'shellescape',
params = { { 'string', 'string' }, { 'special', 'any' } },
@@ -10166,7 +10150,7 @@ M.funcs = {
Returns the effective value of 'shiftwidth'. This is the
'shiftwidth' value unless it is zero, in which case it is the
'tabstop' value. To be backwards compatible in indent
- plugins, use this: >
+ plugins, use this: >vim
if exists('*shiftwidth')
func s:sw()
return shiftwidth()
@@ -10183,11 +10167,9 @@ M.funcs = {
'vartabstop' feature. If no {col} argument is given, column 1
will be assumed.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetColumn()->shiftwidth()
-
- sign_ functions are documented here: |sign-functions-details|
-
+ <
]=],
name = 'shiftwidth',
params = { { 'col', 'integer' } },
@@ -10236,7 +10218,7 @@ M.funcs = {
{list} is used, then returns a List of values one for each
defined sign.
- Examples: >
+ Examples: >vim
call sign_define("mySign", {
\ "text" : "=>",
\ "texthl" : "Error",
@@ -10248,9 +10230,9 @@ M.funcs = {
\ 'text' : '!!'}
\ ])
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignList()->sign_define()
-
+ <
]=],
name = 'sign_define',
params = { { 'list', 'any' } },
@@ -10287,16 +10269,16 @@ M.funcs = {
Returns an empty List if there are no signs and when {name} is
not found.
- Examples: >
+ Examples: >vim
" Get a list of all the defined signs
echo sign_getdefined()
" Get the attribute of the sign named mySign
echo sign_getdefined("mySign")
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignList()->sign_getdefined()
-
+ <
]=],
name = 'sign_getdefined',
params = { { 'name', 'string' } },
@@ -10344,7 +10326,7 @@ M.funcs = {
Returns an empty list on failure or if there are no placed
signs.
- Examples: >
+ Examples: >vim
" Get a List of signs placed in eval.c in the
" global group
echo sign_getplaced("eval.c")
@@ -10365,7 +10347,7 @@ M.funcs = {
" Get a List of all the placed signs
echo sign_getplaced()
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufname()->sign_getplaced()
<
]=],
@@ -10387,11 +10369,11 @@ M.funcs = {
Returns the line number of the sign. Returns -1 if the
arguments are invalid.
- Example: >
+ Example: >vim
" Jump to sign 10 in the current buffer
call sign_jump(10, '', '')
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignid()->sign_jump()
<
]=],
@@ -10431,7 +10413,7 @@ M.funcs = {
Returns the sign identifier on success and -1 on failure.
- Examples: >
+ Examples: >vim
" Place a sign named sign1 with id 5 at line 20 in
" buffer json.c
call sign_place(5, '', 'sign1', 'json.c',
@@ -10450,7 +10432,7 @@ M.funcs = {
call sign_place(10, 'g3', 'sign4', 'json.c',
\ {'lnum' : 40, 'priority' : 90})
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignid()->sign_place(group, name, expr)
<
]=],
@@ -10500,7 +10482,7 @@ M.funcs = {
Returns a List of sign identifiers. If failed to place a
sign, the corresponding list item is set to -1.
- Examples: >
+ Examples: >vim
" Place sign s1 with id 5 at line 20 and id 10 at line
" 30 in buffer a.c
let [n1, n2] = sign_placelist([
@@ -10525,9 +10507,9 @@ M.funcs = {
\ 'lnum' : 50}
\ ])
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignlist()->sign_placelist()
-
+ <
]=],
name = 'sign_placelist',
params = { { 'list', 'any' } },
@@ -10555,7 +10537,7 @@ M.funcs = {
{list} call, returns a list of values one for each undefined
sign.
- Examples: >
+ Examples: >vim
" Delete a sign named mySign
call sign_undefine("mySign")
@@ -10565,9 +10547,9 @@ M.funcs = {
" Delete all the signs
call sign_undefine()
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignlist()->sign_undefine()
-
+ <
]=],
name = 'sign_undefine',
params = { { 'list', 'any' } },
@@ -10593,7 +10575,7 @@ M.funcs = {
Returns 0 on success and -1 on failure.
- Examples: >
+ Examples: >vim
" Remove sign 10 from buffer a.vim
call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
@@ -10618,7 +10600,7 @@ M.funcs = {
" Remove all the placed signs from all the buffers
call sign_unplace('*')
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetSigngroup()->sign_unplace()
<
]=],
@@ -10649,7 +10631,7 @@ M.funcs = {
Returns a List where an entry is set to 0 if the corresponding
sign was successfully removed or -1 on failure.
- Example: >
+ Example: >vim
" Remove sign with id 10 from buffer a.vim and sign
" with id 20 from buffer b.vim
call sign_unplacelist([
@@ -10657,10 +10639,9 @@ M.funcs = {
\ {'id' : 20, 'buffer' : 'b.vim'},
\ ])
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetSignlist()->sign_unplacelist()
<
-
]=],
name = 'sign_unplacelist',
params = { { 'list', 'any' } },
@@ -10678,7 +10659,7 @@ M.funcs = {
not removed either. On Unix "//path" is unchanged, but
"///path" is simplified to "/path" (this follows the Posix
standard).
- Example: >
+ Example: >vim
simplify("./dir/.././/file/") == "./file/"
<Note: The combination "dir/.." is only removed if "dir" is
a searchable directory or does not exist. On Unix, it is also
@@ -10686,9 +10667,9 @@ M.funcs = {
directory. In order to resolve all the involved symbolic
links before simplifying the path name, use |resolve()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetName()->simplify()
-
+ <
]=],
name = 'simplify',
params = { { 'filename', 'any' } },
@@ -10701,15 +10682,15 @@ M.funcs = {
Return the sine of {expr}, measured in radians, as a |Float|.
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo sin(100)
- < -0.506366 >
- :echo sin(-4.01)
+ Examples: >vim
+ echo sin(100)
+ < -0.506366 >vim
+ echo sin(-4.01)
< 0.763301
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->sin()
-
+ <
]=],
float_func = 'sin',
name = 'sin',
@@ -10724,15 +10705,15 @@ M.funcs = {
[-inf, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo sinh(0.5)
- < 0.521095 >
- :echo sinh(-0.9)
+ Examples: >vim
+ echo sinh(0.5)
+ < 0.521095 >vim
+ echo sinh(-0.9)
< -1.026517
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->sinh()
-
+ <
]=],
float_func = 'sinh',
name = 'sinh',
@@ -10751,7 +10732,7 @@ M.funcs = {
When {end} is -1 the last item is omitted.
Returns an empty value if {start} or {end} are invalid.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetList()->slice(offset)
<
]=],
@@ -10785,7 +10766,6 @@ M.funcs = {
Returns:
- The channel ID on success (greater than zero)
- 0 on invalid arguments or connection failure.
-
]=],
name = 'sockconnect',
params = { { 'mode', 'string' }, { 'address', 'any' }, { 'opts', 'table' } },
@@ -10798,8 +10778,8 @@ M.funcs = {
desc = [=[
Sort the items in {list} in-place. Returns {list}.
- If you want a list to remain unmodified make a copy first: >
- :let sortedlist = sort(copy(mylist))
+ If you want a list to remain unmodified make a copy first: >vim
+ let sortedlist = sort(copy(mylist))
<When {func} is omitted, is empty or zero, then sort() uses the
string representation of each item to sort on. Numbers sort
@@ -10814,15 +10794,15 @@ M.funcs = {
is used to compare strings. See |:language| check or set the
collation locale. |v:collate| can also be used to check the
current locale. Sorting using the locale typically ignores
- case. Example: >
+ case. Example: >vim
" ΓΆ is sorted similarly to o with English locale.
- :language collate en_US.UTF8
- :echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
+ language collate en_US.UTF8
+ echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
< ['n', 'o', 'O', 'ΓΆ', 'p', 'z'] ~
- >
+ >vim
" ΓΆ is sorted after z with Swedish locale.
- :language collate sv_SE.UTF8
- :echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
+ language collate sv_SE.UTF8
+ echo sort(['n', 'o', 'O', 'ΓΆ', 'p', 'z'], 'l')
< ['n', 'o', 'O', 'p', 'z', 'ΓΆ'] ~
This does not work properly on Mac.
@@ -10852,22 +10832,22 @@ M.funcs = {
on numbers, text strings will sort next to each other, in the
same order as they were originally.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->sort()
<Also see |uniq()|.
- Example: >
+ Example: >vim
func MyCompare(i1, i2)
return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
endfunc
eval mylist->sort("MyCompare")
<A shorter compare version for this specific simple case, which
- ignores overflow: >
+ ignores overflow: >vim
func MyCompare(i1, i2)
return a:i1 - a:i2
endfunc
- <For a simple expression you can use a lambda: >
+ <For a simple expression you can use a lambda: >vim
eval mylist->sort({i1, i2 -> i1 - i2})
<
]=],
@@ -10886,7 +10866,7 @@ M.funcs = {
This can be used for making spelling suggestions. Note that
the method can be quite slow.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWord()->soundfold()
<
]=],
@@ -10914,14 +10894,14 @@ M.funcs = {
"rare" rare word
"local" word only valid in another region
"caps" word should start with Capital
- Example: >
+ Example: >vim
echo spellbadword("the quik brown fox")
< ['quik', 'bad'] ~
The spelling information for the current window and the value
of 'spelllang' are used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->spellbadword()
<
]=],
@@ -10953,9 +10933,9 @@ M.funcs = {
The spelling information for the current window is used. The
values of 'spelllang' and 'spellsuggest' are used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWord()->spellsuggest()
-
+ <
]=],
name = 'spellsuggest',
params = { { 'word', 'any' }, { 'max', 'any' }, { 'capital', 'any' } },
@@ -10975,21 +10955,23 @@ M.funcs = {
{keepempty} argument is given and it's non-zero.
Other empty items are kept when {pattern} matches at least one
character or when {keepempty} is non-zero.
- Example: >
- :let words = split(getline('.'), '\W\+')
- <To split a string in individual characters: >
- :for c in split(mystring, '\zs')
+ Example: >vim
+ let words = split(getline('.'), '\W\+')
+ <To split a string in individual characters: >vim
+ for c in split(mystring, '\zs') | endfor
<If you want to keep the separator you can also use '\zs' at
- the end of the pattern: >
- :echo split('abc:def:ghi', ':\zs')
- < ['abc:', 'def:', 'ghi'] ~
- Splitting a table where the first element can be empty: >
- :let items = split(line, ':', 1)
+ the end of the pattern: >vim
+ echo split('abc:def:ghi', ':\zs')
+ < >
+ ['abc:', 'def:', 'ghi']
+ <
+ Splitting a table where the first element can be empty: >vim
+ let items = split(line, ':', 1)
<The opposite function is |join()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->split()
-
+ <
]=],
name = 'split',
params = { { 'string', 'string' }, { 'pattern', 'any' }, { 'keepempty', 'any' } },
@@ -11004,16 +10986,16 @@ M.funcs = {
{expr} must evaluate to a |Float| or a |Number|. When {expr}
is negative the result is NaN (Not a Number). Returns 0.0 if
{expr} is not a |Float| or a |Number|.
- Examples: >
- :echo sqrt(100)
- < 10.0 >
- :echo sqrt(-4.01)
+ Examples: >vim
+ echo sqrt(100)
+ < 10.0 >vim
+ echo sqrt(-4.01)
< str2float("nan")
NaN may be different, it depends on system libraries.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->sqrt()
-
+ <
]=],
float_func = 'sqrt',
name = 'sqrt',
@@ -11032,14 +11014,14 @@ M.funcs = {
initialize the seed values. This is useful for testing or
when a predictable sequence is intended.
- Examples: >
- :let seed = srand()
- :let seed = srand(userinput)
- :echo rand(seed)
+ Examples: >vim
+ let seed = srand()
+ let seed = srand(userinput)
+ echo rand(seed)
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
userinput->srand()
-
+ <
]=],
name = 'srand',
params = { { 'expr', 'any' } },
@@ -11093,8 +11075,8 @@ M.funcs = {
state String Session state directory: storage for file
drafts, swap, undo, |shada|.
- Example: >
- :echo stdpath("config")
+ Example: >vim
+ echo stdpath("config")
<
]=],
fast = true,
@@ -11119,14 +11101,14 @@ M.funcs = {
The decimal point is always '.', no matter what the locale is
set to. A comma ends the number: "12,345.67" is converted to
12.0. You can strip out thousands separators with
- |substitute()|: >
+ |substitute()|: >vim
let f = str2float(substitute(text, ',', '', 'g'))
<
Returns 0.0 if the conversion fails.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
let f = text->substitute(',', '', 'g')->str2float()
-
+ <
]=],
name = 'str2float',
params = { { 'string', 'string' }, { 'quoted', 'any' } },
@@ -11137,19 +11119,19 @@ M.funcs = {
base = 1,
desc = [=[
Return a list containing the number values which represent
- each character in String {string}. Examples: >
- str2list(" ") returns [32]
- str2list("ABC") returns [65, 66, 67]
+ each character in String {string}. Examples: >vim
+ echo str2list(" ") " returns [32]
+ echo str2list("ABC") " returns [65, 66, 67]
<|list2str()| does the opposite.
UTF-8 encoding is always used, {utf8} option has no effect,
and exists only for backwards-compatibility.
- With UTF-8 composing characters are handled properly: >
- str2list("á") returns [97, 769]
+ With UTF-8 composing characters are handled properly: >vim
+ echo str2list("á") " returns [97, 769]
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetString()->str2list()
-
+ <
]=],
name = 'str2list',
params = { { 'string', 'string' }, { 'utf8', 'any' } },
@@ -11166,7 +11148,7 @@ M.funcs = {
When {base} is omitted base 10 is used. This also means that
a leading zero doesn't cause octal conversion to be used, as
- with the default String to Number conversion. Example: >
+ with the default String to Number conversion. Example: >vim
let nr = str2nr('0123')
<
When {base} is 16 a leading "0x" or "0X" is ignored. With a
@@ -11177,7 +11159,7 @@ M.funcs = {
Returns 0 if {string} is empty or on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->str2nr()
<
]=],
@@ -11198,7 +11180,7 @@ M.funcs = {
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strcharlen()
<
]=],
@@ -11218,13 +11200,13 @@ M.funcs = {
similar to |slice()|.
When a character index is used where a character does not
exist it is omitted and counted as one character. For
- example: >
- strcharpart('abc', -1, 2)
+ example: >vim
+ echo strcharpart('abc', -1, 2)
<results in 'a'.
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strcharpart(5)
<
]=],
@@ -11249,7 +11231,7 @@ M.funcs = {
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
{skipcc} is only available after 7.4.755. For backward
- compatibility, you can define a wrapper function: >
+ compatibility, you can define a wrapper function: >vim
if has("patch-7.4.755")
function s:strchars(str, skipcc)
return strchars(a:str, a:skipcc)
@@ -11264,9 +11246,9 @@ M.funcs = {
endfunction
endif
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strchars()
-
+ <
]=],
name = 'strchars',
params = { { 'string', 'string' }, { 'skipcc', 'any' } },
@@ -11289,9 +11271,9 @@ M.funcs = {
Returns zero on error.
Also see |strlen()|, |strwidth()| and |strchars()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strdisplaywidth()
-
+ <
]=],
name = 'strdisplaywidth',
params = { { 'string', 'string' }, { 'col', 'integer' } },
@@ -11309,17 +11291,17 @@ M.funcs = {
format. The maximum length of the result is 80 characters.
See also |localtime()|, |getftime()| and |strptime()|.
The language can be changed with the |:language| command.
- Examples: >
- :echo strftime("%c") Sun Apr 27 11:49:23 1997
- :echo strftime("%Y %b %d %X") 1997 Apr 27 11:53:25
- :echo strftime("%y%m%d %T") 970427 11:53:55
- :echo strftime("%H:%M") 11:55
- :echo strftime("%c", getftime("file.c"))
- Show mod time of file.c.
-
- <Can also be used as a |method|: >
+ Examples: >vim
+ echo strftime("%c") " Sun Apr 27 11:49:23 1997
+ echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
+ echo strftime("%y%m%d %T") " 970427 11:53:55
+ echo strftime("%H:%M") " 11:55
+ echo strftime("%c", getftime("file.c"))
+ " Show mod time of file.c.
+
+ <Can also be used as a |method|: >vim
GetFormat()->strftime()
-
+ <
]=],
name = 'strftime',
params = { { 'format', 'any' }, { 'time', 'any' } },
@@ -11337,9 +11319,9 @@ M.funcs = {
Returns -1 if {index} is invalid.
Also see |strcharpart()| and |strchars()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strgetchar(5)
-
+ <
]=],
name = 'strgetchar',
params = { { 'str', 'any' }, { 'index', 'any' } },
@@ -11352,22 +11334,22 @@ M.funcs = {
The result is a Number, which gives the byte index in
{haystack} of the first occurrence of the String {needle}.
If {start} is specified, the search starts at index {start}.
- This can be used to find a second match: >
- :let colon1 = stridx(line, ":")
- :let colon2 = stridx(line, ":", colon1 + 1)
+ This can be used to find a second match: >vim
+ let colon1 = stridx(line, ":")
+ let colon2 = stridx(line, ":", colon1 + 1)
<The search is done case-sensitive.
For pattern searches use |match()|.
-1 is returned if the {needle} does not occur in {haystack}.
See also |strridx()|.
- Examples: >
- :echo stridx("An Example", "Example") 3
- :echo stridx("Starting point", "Start") 0
- :echo stridx("Starting point", "start") -1
+ Examples: >vim
+ echo stridx("An Example", "Example") " 3
+ echo stridx("Starting point", "Start") " 0
+ echo stridx("Starting point", "start") " -1
< *strstr()* *strchr()*
stridx() works similar to the C function strstr(). When used
with a single character it works similar to strchr().
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHaystack()->stridx(needle)
<
]=],
@@ -11403,9 +11385,9 @@ M.funcs = {
method, use |msgpackdump()| or |json_encode()| if you need to
share data with other application.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->string()
-
+ <
]=],
name = 'string',
params = { { 'expr', 'any' } },
@@ -11423,9 +11405,9 @@ M.funcs = {
|strchars()|.
Also see |len()|, |strdisplaywidth()| and |strwidth()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->strlen()
-
+ <
]=],
name = 'strlen',
params = { { 'string', 'string' } },
@@ -11447,21 +11429,21 @@ M.funcs = {
When bytes are selected which do not exist, this doesn't
result in an error, the bytes are simply omitted.
If {len} is missing, the copy continues from {start} till the
- end of the {src}. >
- strpart("abcdefg", 3, 2) == "de"
- strpart("abcdefg", -2, 4) == "ab"
- strpart("abcdefg", 5, 4) == "fg"
- strpart("abcdefg", 3) == "defg"
+ end of the {src}. >vim
+ echo strpart("abcdefg", 3, 2) " returns 'de'
+ echo strpart("abcdefg", -2, 4) " returns 'ab'
+ echo strpart("abcdefg", 5, 4) " returns 'fg'
+ echo strpart("abcdefg", 3) " returns 'defg'
<Note: To get the first character, {start} must be 0. For
- example, to get the character under the cursor: >
+ example, to get the character under the cursor: >vim
strpart(getline("."), col(".") - 1, 1, v:true)
<
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->strpart(5)
-
+ <
]=],
fast = true,
name = 'strpart',
@@ -11487,15 +11469,15 @@ M.funcs = {
result.
See also |strftime()|.
- Examples: >
- :echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
- < 862156163 >
- :echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
- < Sun Apr 27 11:53:55 1997 >
- :echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
+ Examples: >vim
+ echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
+ < 862156163 >vim
+ echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
+ < Sun Apr 27 11:53:55 1997 >vim
+ echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
< Sun Apr 27 12:53:55 1997
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFormat()->strptime(timestring)
<
]=],
@@ -11511,22 +11493,22 @@ M.funcs = {
{haystack} of the last occurrence of the String {needle}.
When {start} is specified, matches beyond this index are
ignored. This can be used to find a match before a previous
- match: >
- :let lastcomma = strridx(line, ",")
- :let comma2 = strridx(line, ",", lastcomma - 1)
+ match: >vim
+ let lastcomma = strridx(line, ",")
+ let comma2 = strridx(line, ",", lastcomma - 1)
<The search is done case-sensitive.
For pattern searches use |match()|.
-1 is returned if the {needle} does not occur in {haystack}.
If the {needle} is empty the length of {haystack} is returned.
- See also |stridx()|. Examples: >
- :echo strridx("an angry armadillo", "an") 3
+ See also |stridx()|. Examples: >vim
+ echo strridx("an angry armadillo", "an") 3
< *strrchr()*
When used with a single character it works similar to the C
function strrchr().
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetHaystack()->strridx(needle)
-
+ <
]=],
name = 'strridx',
params = { { 'haystack', 'any' }, { 'needle', 'any' }, { 'start', 'any' } },
@@ -11538,16 +11520,16 @@ M.funcs = {
desc = [=[
The result is a String, which is {string} with all unprintable
characters translated into printable characters |'isprint'|.
- Like they are shown in a window. Example: >
+ Like they are shown in a window. Example: >vim
echo strtrans(@a)
<This displays a newline in register a as "^@" instead of
starting a new line.
Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->strtrans()
-
+ <
]=],
fast = true,
name = 'strtrans',
@@ -11569,14 +11551,14 @@ M.funcs = {
Returns zero on error.
Also see |strlen()| and |strcharlen()|.
- Examples: >
- echo strutf16len('a') returns 1
- echo strutf16len('Β©') returns 1
- echo strutf16len('😊') returns 2
- echo strutf16len('ą́') returns 1
- echo strutf16len('ą́', v:true) returns 3
-
- Can also be used as a |method|: >
+ Examples: >vim
+ echo strutf16len('a') " returns 1
+ echo strutf16len('Β©') " returns 1
+ echo strutf16len('😊') " returns 2
+ echo strutf16len('ą́') " returns 1
+ echo strutf16len('ą́', v:true) " returns 3
+
+ Can also be used as a |method|: >vim
GetText()->strutf16len()
<
]=],
@@ -11596,9 +11578,9 @@ M.funcs = {
Returns zero on error.
Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->strwidth()
-
+ <
]=],
fast = true,
name = 'strwidth',
@@ -11631,15 +11613,15 @@ M.funcs = {
Returns an empty string or list on error.
- Examples: >
- :s/\d\+/\=submatch(0) + 1/
- :echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
+ Examples: >vim
+ s/\d\+/\=submatch(0) + 1/
+ echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
<This finds the first number in the line and adds one to it.
A line break is included as a newline character.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetNr()->submatch()
-
+ <
]=],
name = 'submatch',
params = { { 'nr', 'integer' }, { 'list', 'any' } },
@@ -11670,30 +11652,30 @@ M.funcs = {
When {pat} does not match in {string}, {string} is returned
unmodified.
- Example: >
- :let &path = substitute(&path, ",\\=[^,]*$", "", "")
- <This removes the last component of the 'path' option. >
- :echo substitute("testing", ".*", "\\U\\0", "")
+ Example: >vim
+ let &path = substitute(&path, ",\\=[^,]*$", "", "")
+ <This removes the last component of the 'path' option. >vim
+ echo substitute("testing", ".*", "\\U\\0", "")
<results in "TESTING".
When {sub} starts with "\=", the remainder is interpreted as
- an expression. See |sub-replace-expression|. Example: >
- :echo substitute(s, '%\(\x\x\)',
+ an expression. See |sub-replace-expression|. Example: >vim
+ echo substitute(s, '%\(\x\x\)',
\ '\=nr2char("0x" .. submatch(1))', 'g')
<When {sub} is a Funcref that function is called, with one
- optional argument. Example: >
- :echo substitute(s, '%\(\x\x\)', SubNr, 'g')
+ optional argument. Example: >vim
+ echo substitute(s, '%\(\x\x\)', SubNr, 'g')
<The optional argument is a list which contains the whole
matched string and up to nine submatches, like what
- |submatch()| returns. Example: >
- :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
+ |submatch()| returns. Example: >vim
+ echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
<Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetString()->substitute(pat, sub, flags)
-
+ <
]=],
name = 'substitute',
params = { { 'string', 'string' }, { 'pat', 'any' }, { 'sub', 'any' }, { 'flags', 'string' } },
@@ -11705,12 +11687,11 @@ M.funcs = {
See the |-r| command argument. The 'directory' option is used
for the directories to inspect. If you only want to get a
list of swap files in the current directory then temporarily
- set 'directory' to a dot: >
+ set 'directory' to a dot: >vim
let save_dir = &directory
let &directory = '.'
let swapfiles = swapfilelist()
let &directory = save_dir
-
]=],
name = 'swapfilelist',
params = {},
@@ -11737,9 +11718,9 @@ M.funcs = {
Not a swap file: does not contain correct block ID
Magic number mismatch: Info in first block is invalid
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->swapinfo()
-
+ <
]=],
name = 'swapinfo',
params = { { 'fname', 'integer' } },
@@ -11755,9 +11736,9 @@ M.funcs = {
|:swapname| (unless there is no swap file).
If buffer {buf} has no swap file, returns an empty string.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufname()->swapname()
-
+ <
]=],
name = 'swapname',
params = { { 'buf', 'any' } },
@@ -11787,10 +11768,9 @@ M.funcs = {
Returns zero on error.
- Example (echoes the name of the syntax item under the cursor): >
- :echo synIDattr(synID(line("."), col("."), 1), "name")
+ Example (echoes the name of the syntax item under the cursor): >vim
+ echo synIDattr(synID(line("."), col("."), 1), "name")
<
-
]=],
name = 'synID',
params = { { 'lnum', 'integer' }, { 'col', 'integer' }, { 'trans', 'any' } },
@@ -11838,12 +11818,12 @@ M.funcs = {
Returns an empty string on error.
Example (echoes the color of the syntax item under the
- cursor): >
- :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
+ cursor): >vim
+ echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
+ <
+ Can also be used as a |method|: >vim
+ echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
<
- Can also be used as a |method|: >
- :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
-
]=],
name = 'synIDattr',
params = { { 'synID', 'any' }, { 'what', 'any' }, { 'mode', 'string' } },
@@ -11860,9 +11840,9 @@ M.funcs = {
Returns zero on error.
- Can also be used as a |method|: >
- :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
-
+ Can also be used as a |method|: >vim
+ echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
+ <
]=],
name = 'synIDtrans',
params = { { 'synID', 'any' } },
@@ -11912,7 +11892,7 @@ M.funcs = {
returns, unless not the whole item is highlighted or it is a
transparent item.
This function is useful for debugging a syntax file.
- Example that shows the syntax stack under the cursor: >
+ Example that shows the syntax stack under the cursor: >vim
for id in synstack(line("."), col("."))
echo synIDattr(id, "name")
endfor
@@ -11920,7 +11900,6 @@ M.funcs = {
an empty list is returned. The position just after the last
character in a line and the first column in an empty line are
valid positions.
-
]=],
name = 'synstack',
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },
@@ -11937,8 +11916,8 @@ M.funcs = {
a |List|) and sets |v:shell_error| to the error code.
{cmd} is treated as in |jobstart()|:
If {cmd} is a List it runs directly (no 'shell').
- If {cmd} is a String it runs in the 'shell', like this: >
- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+ If {cmd} is a String it runs in the 'shell', like this: >vim
+ call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
<Not to be used for interactive commands.
@@ -11946,8 +11925,8 @@ M.funcs = {
- <CR><NL> is replaced with <NL>
- NUL characters are replaced with SOH (0x01)
- Example: >
- :echo system(['ls', expand('%:h')])
+ Example: >vim
+ echo system(['ls', expand('%:h')])
<If {input} is a string it is written to a pipe and passed as
stdin to the command. The string is written as-is, line
@@ -11961,8 +11940,8 @@ M.funcs = {
terminated by NL (and NUL where the text has NL).
*E5677*
Note: system() cannot write to or read from backgrounded ("&")
- shell commands, e.g.: >
- :echo system("cat - &", "foo")
+ shell commands, e.g.: >vim
+ echo system("cat - &", "foo")
<which is equivalent to: >
$ echo foo | bash -c 'cat - &'
<The pipes are disconnected (unless overridden by shell
@@ -11972,16 +11951,16 @@ M.funcs = {
Note: Use |shellescape()| or |::S| with |expand()| or
|fnamemodify()| to escape special characters in a command
argument. 'shellquote' and 'shellxquote' must be properly
- configured. Example: >
- :echo system('ls '..shellescape(expand('%:h')))
- :echo system('ls '..expand('%:h:S'))
+ configured. Example: >vim
+ echo system('ls '..shellescape(expand('%:h')))
+ echo system('ls '..expand('%:h:S'))
<Unlike ":!cmd" there is no automatic check for changed files.
Use |:checktime| to force a check.
- Can also be used as a |method|: >
- :echo GetCmd()->system()
-
+ Can also be used as a |method|: >vim
+ echo GetCmd()->system()
+ <
]=],
name = 'system',
params = { { 'cmd', 'any' }, { 'input', 'any' } },
@@ -11999,14 +11978,14 @@ M.funcs = {
Note that on MS-Windows you may get trailing CR characters.
To see the difference between "echo hello" and "echo -n hello"
- use |system()| and |split()|: >
+ use |system()| and |split()|: >vim
echo split(system('echo hello'), '\n', 1)
<
Returns an empty string on error.
- Can also be used as a |method|: >
- :echo GetCmd()->systemlist()
-
+ Can also be used as a |method|: >vim
+ echo GetCmd()->systemlist()
+ <
]=],
name = 'systemlist',
params = { { 'cmd', 'any' }, { 'input', 'any' }, { 'keepempty', 'any' } },
@@ -12021,16 +12000,16 @@ M.funcs = {
{arg} specifies the number of the tab page to be used. When
omitted the current tab page is used.
When {arg} is invalid the number zero is returned.
- To get a list of all buffers in all tabs use this: >
+ To get a list of all buffers in all tabs use this: >vim
let buflist = []
for i in range(tabpagenr('$'))
call extend(buflist, tabpagebuflist(i + 1))
endfor
<Note that a buffer may appear in more than one window.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabpage()->tabpagebuflist()
-
+ <
]=],
name = 'tabpagebuflist',
params = { { 'arg', 'any' } },
@@ -12051,7 +12030,6 @@ M.funcs = {
The number can be used with the |:tab| command.
Returns zero on error.
-
]=],
name = 'tabpagenr',
params = { { 'arg', 'any' } },
@@ -12068,12 +12046,12 @@ M.funcs = {
the window which will be used when going to this tab page.
- When "$" the number of windows is returned.
- When "#" the previous window nr is returned.
- Useful examples: >
+ Useful examples: >vim
tabpagewinnr(1) " current window of tab page 1
tabpagewinnr(4, '$') " number of windows in tab page 4
<When {tabarg} is invalid zero is returned.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabpage()->tabpagewinnr()
<
]=],
@@ -12136,9 +12114,8 @@ M.funcs = {
located by Vim. Refer to |tags-file-format| for the format of
the tags file generated by the different ctags tools.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTagpattern()->taglist()
-
]=],
name = 'taglist',
params = { { 'expr', 'any' }, { 'filename', 'any' } },
@@ -12152,15 +12129,15 @@ M.funcs = {
in the range [-inf, inf].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo tan(10)
- < 0.648361 >
- :echo tan(-4.01)
+ Examples: >vim
+ echo tan(10)
+ < 0.648361 >vim
+ echo tan(-4.01)
< -1.181502
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->tan()
-
+ <
]=],
float_func = 'tan',
name = 'tan',
@@ -12175,13 +12152,13 @@ M.funcs = {
range [-1, 1].
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
- :echo tanh(0.5)
- < 0.462117 >
- :echo tanh(-1)
+ Examples: >vim
+ echo tanh(0.5)
+ < 0.462117 >vim
+ echo tanh(-1)
< -0.761594
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->tanh()
<
]=],
@@ -12194,10 +12171,10 @@ M.funcs = {
desc = [=[
Generates a (non-existent) filename located in the Nvim root
|tempdir|. Scripts can use the filename as a temporary file.
- Example: >
- :let tmpfile = tempname()
- :exe "redir > " .. tmpfile
-
+ Example: >vim
+ let tmpfile = tempname()
+ exe "redir > " .. tmpfile
+ <
]=],
name = 'tempname',
params = {},
@@ -12220,7 +12197,6 @@ M.funcs = {
Terminal environment is initialized as in |jobstart-env|,
except $TERM is set to "xterm-256color". Full behavior is
described in |terminal|.
-
]=],
name = 'termopen',
params = { { 'cmd', 'any' }, { 'opts', 'table' } },
@@ -12251,7 +12227,7 @@ M.funcs = {
-1 means forever
"callback" the callback
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimer()->timer_info()
<
]=],
@@ -12275,7 +12251,7 @@ M.funcs = {
String, then the timer is paused, otherwise it is unpaused.
See |non-zero-arg|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimer()->timer_pause(1)
<
]=],
@@ -12309,7 +12285,7 @@ M.funcs = {
Returns -1 on error.
- Example: >
+ Example: >vim
func MyHandler(timer)
echo 'Handler called'
endfunc
@@ -12317,11 +12293,10 @@ M.funcs = {
\ {'repeat': 3})
<This invokes MyHandler() three times at 500 msec intervals.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetMsec()->timer_start(callback)
<Not available in the |sandbox|.
-
]=],
name = 'timer_start',
params = { { 'time', 'any' }, { 'callback', 'any' }, { 'options', 'table' } },
@@ -12335,7 +12310,7 @@ M.funcs = {
{timer} is an ID returned by timer_start(), thus it must be a
Number. If {timer} does not exist there is no error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTimer()->timer_stop()
<
]=],
@@ -12349,7 +12324,6 @@ M.funcs = {
Stop all timers. The timer callbacks will no longer be
invoked. Useful if some timers is misbehaving. If there are
no timers there is no error.
-
]=],
name = 'timer_stopall',
params = {},
@@ -12363,9 +12337,9 @@ M.funcs = {
characters turned into lowercase (just like applying |gu| to
the string). Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->tolower()
-
+ <
]=],
fast = true,
name = 'tolower',
@@ -12381,9 +12355,9 @@ M.funcs = {
characters turned into uppercase (just like applying |gU| to
the string). Returns an empty string on error.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->toupper()
-
+ <
]=],
fast = true,
name = 'toupper',
@@ -12404,15 +12378,15 @@ M.funcs = {
Returns an empty string on error.
- Examples: >
+ Examples: >vim
echo tr("hello there", "ht", "HT")
- <returns "Hello THere" >
+ <returns "Hello THere" >vim
echo tr("<blob>", "<>", "{}")
<returns "{blob}"
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->tr(from, to)
-
+ <
]=],
name = 'tr',
params = { { 'src', 'any' }, { 'fromstr', 'any' }, { 'tostr', 'any' } },
@@ -12436,19 +12410,19 @@ M.funcs = {
This function deals with multibyte characters properly.
Returns an empty string on error.
- Examples: >
+ Examples: >vim
echo trim(" some text ")
- <returns "some text" >
+ <returns "some text" >vim
echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
- <returns "RESERVE_TAIL" >
+ <returns "RESERVE_TAIL" >vim
echo trim("rm<Xrm<>X>rrm", "rm<>")
- <returns "Xrm<>X" (characters in the middle are not removed) >
+ <returns "Xrm<>X" (characters in the middle are not removed) >vim
echo trim(" vim ", " ", 2)
<returns " vim"
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetText()->trim()
-
+ <
]=],
name = 'trim',
params = { { 'text', 'any' }, { 'mask', 'any' }, { 'dir', 'string' } },
@@ -12463,17 +12437,17 @@ M.funcs = {
equal to {expr} as a |Float| (truncate towards zero).
{expr} must evaluate to a |Float| or a |Number|.
Returns 0.0 if {expr} is not a |Float| or a |Number|.
- Examples: >
+ Examples: >vim
echo trunc(1.456)
- < 1.0 >
+ < 1.0 >vim
echo trunc(-5.456)
- < -5.0 >
+ < -5.0 >vim
echo trunc(4.0)
< 4.0
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
Compute()->trunc()
-
+ <
]=],
float_func = 'trunc',
name = 'trunc',
@@ -12496,23 +12470,23 @@ M.funcs = {
Boolean: 6 (|v:true| and |v:false|)
Null: 7 (|v:null|)
Blob: 10 (|v:t_blob|)
- For backward compatibility, this method can be used: >
- :if type(myvar) == type(0)
- :if type(myvar) == type("")
- :if type(myvar) == type(function("tr"))
- :if type(myvar) == type([])
- :if type(myvar) == type({})
- :if type(myvar) == type(0.0)
- :if type(myvar) == type(v:true)
+ For backward compatibility, this method can be used: >vim
+ if type(myvar) == type(0) | endif
+ if type(myvar) == type("") | endif
+ if type(myvar) == type(function("tr")) | endif
+ if type(myvar) == type([]) | endif
+ if type(myvar) == type({}) | endif
+ if type(myvar) == type(0.0) | endif
+ if type(myvar) == type(v:true) | endif
<In place of checking for |v:null| type it is better to check
- for |v:null| directly as it is the only value of this type: >
- :if myvar is v:null
- < To check if the v:t_ variables exist use this: >
- :if exists('v:t_number')
+ for |v:null| directly as it is the only value of this type: >vim
+ if myvar is v:null | endif
+ <To check if the v:t_ variables exist use this: >vim
+ if exists('v:t_number') | endif
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
mylist->type()
-
+ <
]=],
fast = true,
name = 'type',
@@ -12533,9 +12507,9 @@ M.funcs = {
buffer without a file name will not write an undo file.
Useful in combination with |:wundo| and |:rundo|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetFilename()->undofile()
-
+ <
]=],
name = 'undofile',
params = { { 'name', 'string' } },
@@ -12585,7 +12559,6 @@ M.funcs = {
"alt" Alternate entry. This is again a List of undo
blocks. Each item may again have an "alt"
item.
-
]=],
name = 'undotree',
params = {},
@@ -12598,14 +12571,14 @@ M.funcs = {
desc = [=[
Remove second and succeeding copies of repeated adjacent
{list} items in-place. Returns {list}. If you want a list
- to remain unmodified make a copy first: >
- :let newlist = uniq(copy(mylist))
+ to remain unmodified make a copy first: >vim
+ let newlist = uniq(copy(mylist))
<The default compare function uses the string representation of
each item. For the use of {func} and {dict} see |sort()|.
Returns zero if {list} is not a |List|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mylist->uniq()
<
]=],
@@ -12635,16 +12608,16 @@ M.funcs = {
from the UTF-16 index and |charidx()| for getting the
character index from the UTF-16 index.
Refer to |string-offset-encoding| for more information.
- Examples: >
- echo utf16idx('a😊😊', 3) returns 2
- echo utf16idx('a😊😊', 7) returns 4
- echo utf16idx('a😊😊', 1, 0, 1) returns 2
- echo utf16idx('a😊😊', 2, 0, 1) returns 4
- echo utf16idx('aą́c', 6) returns 2
- echo utf16idx('aą́c', 6, 1) returns 4
- echo utf16idx('a😊😊', 9) returns -1
- <
- Can also be used as a |method|: >
+ Examples: >vim
+ echo utf16idx('a😊😊', 3) " returns 2
+ echo utf16idx('a😊😊', 7) " returns 4
+ echo utf16idx('a😊😊', 1, 0, 1) " returns 2
+ echo utf16idx('a😊😊', 2, 0, 1) " returns 4
+ echo utf16idx('aą́c', 6) " returns 2
+ echo utf16idx('aą́c', 6, 1) " returns 4
+ echo utf16idx('a😊😊', 9) " returns -1
+ <
+ Can also be used as a |method|: >vim
GetName()->utf16idx(idx)
<
]=],
@@ -12666,9 +12639,9 @@ M.funcs = {
in arbitrary order. Also see |items()| and |keys()|.
Returns zero if {dict} is not a |Dict|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
mydict->values()
-
+ <
]=],
name = 'values',
params = { { 'dict', 'any' } },
@@ -12714,24 +12687,24 @@ M.funcs = {
character.
Note that only marks in the current file can be used.
- Examples: >
+ Examples: >vim
" With text "foo^Lbar" and cursor on the "^L":
- virtcol(".") " returns 5
- virtcol(".", 1) " returns [4, 5]
- virtcol("$") " returns 9
+ echo virtcol(".") " returns 5
+ echo virtcol(".", 1) " returns [4, 5]
+ echo virtcol("$") " returns 9
" With text " there", with 't at 'h':
- virtcol("'t") " returns 6
- <The first column is 1. 0 is returned for an error.
- A more advanced example that echoes the maximum length of
- all lines: >
+ echo virtcol("'t") " returns 6
+ <Techo he first column is 1. 0 is returned for an error.
+ A echo more advanced example that echoes the maximum length of
+ all lines: >vim
echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetPos()->virtcol()
-
+ <
]=],
name = 'virtcol',
params = { { 'expr', 'any' }, { 'list', 'any' } },
@@ -12757,9 +12730,9 @@ M.funcs = {
See also |screenpos()|, |virtcol()| and |col()|.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->virtcol2col(lnum, col)
-
+ <
]=],
name = 'virtcol2col',
params = { { 'winid', 'integer' }, { 'lnum', 'integer' }, { 'col', 'integer' } },
@@ -12774,8 +12747,8 @@ M.funcs = {
"V", or "<CTRL-V>" (a single CTRL-V character) for
character-wise, line-wise, or block-wise Visual mode
respectively.
- Example: >
- :exe "normal " .. visualmode()
+ Example: >vim
+ exe "normal " .. visualmode()
<This enters the same Visual mode as before. It is also useful
in scripts if you wish to act differently depending on the
Visual mode that was used.
@@ -12784,7 +12757,6 @@ M.funcs = {
If {expr} is supplied and it evaluates to a non-zero Number or
a non-empty String, then the Visual mode will be cleared and
the old value is returned. See |non-zero-arg|.
-
]=],
name = 'visualmode',
params = { { 'expr', 'any' } },
@@ -12807,7 +12779,6 @@ M.funcs = {
-1 if the timeout was exceeded
-2 if the function was interrupted (by |CTRL-C|)
-3 if an error occurred
-
]=],
name = 'wait',
params = { { 'timeout', 'integer' }, { 'condition', 'any' }, { 'interval', 'any' } },
@@ -12820,11 +12791,10 @@ M.funcs = {
This can be used in mappings to handle the 'wildcharm' option
gracefully. (Makes only sense with |mapmode-c| mappings).
- For example to make <c-j> work like <down> in wildmode, use: >
- :cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
+ For example to make <c-j> work like <down> in wildmode, use: >vim
+ cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
<
(Note, this needs the 'wildcharm' option set appropriately).
-
]=],
name = 'wildmenumode',
params = {},
@@ -12839,7 +12809,7 @@ M.funcs = {
without triggering autocommands or changing directory. When
executing {command} autocommands will be triggered, this may
have unexpected side effects. Use `:noautocmd` if needed.
- Example: >
+ Example: >vim
call win_execute(winid, 'syntax enable')
<Doing the same with `setwinvar()` would not trigger
autocommands and not actually show syntax highlighting.
@@ -12848,9 +12818,9 @@ M.funcs = {
an empty string is returned.
Can also be used as a |method|, the base is passed as the
- second argument: >
+ second argument: >vim
GetCommand()->win_execute(winid)
-
+ <
]=],
name = 'win_execute',
params = { { 'id', 'any' }, { 'command', 'any' }, { 'silent', 'boolean' } },
@@ -12863,9 +12833,9 @@ M.funcs = {
Returns a |List| with |window-ID|s for windows that contain
buffer {bufnr}. When there is none the list is empty.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetBufnr()->win_findbuf()
-
+ <
]=],
name = 'win_findbuf',
params = { { 'bufnr', 'any' } },
@@ -12884,9 +12854,9 @@ M.funcs = {
number {tab}. The first tab has number one.
Return zero if the window cannot be found.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->win_getid()
-
+ <
]=],
name = 'win_getid',
params = { { 'win', 'any' }, { 'tab', 'any' } },
@@ -12914,7 +12884,7 @@ M.funcs = {
Also see the 'buftype' option.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_gettype()
<
]=],
@@ -12931,9 +12901,9 @@ M.funcs = {
tabpage.
Return TRUE if successful, FALSE if the window cannot be found.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_gotoid()
-
+ <
]=],
name = 'win_gotoid',
params = { { 'expr', 'any' } },
@@ -12948,9 +12918,9 @@ M.funcs = {
with ID {expr}: [tabnr, winnr].
Return [0, 0] if the window cannot be found.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_id2tabwin()
-
+ <
]=],
name = 'win_id2tabwin',
params = { { 'expr', 'any' } },
@@ -12963,9 +12933,9 @@ M.funcs = {
Return the window number of window with ID {expr}.
Return 0 if the window cannot be found in the current tabpage.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_id2win()
-
+ <
]=],
name = 'win_id2win',
params = { { 'expr', 'any' } },
@@ -12989,9 +12959,9 @@ M.funcs = {
window, since it has no separator on the right.
Only works for the current tab page. *E1308*
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->win_move_separator(offset)
-
+ <
]=],
name = 'win_move_separator',
params = { { 'nr', 'integer' }, { 'offset', 'any' } },
@@ -13012,9 +12982,9 @@ M.funcs = {
be found and FALSE otherwise.
Only works for the current tab page.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinnr()->win_move_statusline(offset)
-
+ <
]=],
name = 'win_move_statusline',
params = { { 'nr', 'integer' }, { 'offset', 'any' } },
@@ -13032,7 +13002,7 @@ M.funcs = {
Returns [0, 0] if the window cannot be found in the current
tabpage.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_screenpos()
<
]=],
@@ -13063,7 +13033,7 @@ M.funcs = {
present, the values of 'splitbelow' and
'splitright' are used.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->win_splitmove(target)
<
]=],
@@ -13081,10 +13051,10 @@ M.funcs = {
When {nr} is zero, the number of the buffer in the current
window is returned.
When window {nr} doesn't exist, -1 is returned.
- Example: >
- :echo "The file in the current window is " .. bufname(winbufnr(0))
+ Example: >vim
+ echo "The file in the current window is " .. bufname(winbufnr(0))
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
FindWindow()->winbufnr()->bufname()
<
]=],
@@ -13110,7 +13080,6 @@ M.funcs = {
version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
Windows XP is "5.1". For non-MS-Windows systems the result is
an empty string.
-
]=],
fast = true,
name = 'windowsversion',
@@ -13128,10 +13097,10 @@ M.funcs = {
returned. When window {nr} doesn't exist, -1 is returned.
An existing window always has a height of zero or more.
This excludes any window toolbar line.
- Examples: >
- :echo "The current window has " .. winheight(0) .. " lines."
+ Examples: >vim
+ echo "The current window has " .. winheight(0) .. " lines."
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetWinid()->winheight()
<
]=],
@@ -13151,29 +13120,35 @@ M.funcs = {
with number {tabnr}. If the tabpage {tabnr} is not found,
returns an empty list.
- For a leaf window, it returns:
+ For a leaf window, it returns: >
["leaf", {winid}]
+ <
For horizontally split windows, which form a column, it
returns: >
["col", [{nested list of windows}]]
<For vertically split windows, which form a row, it returns: >
["row", [{nested list of windows}]]
<
- Example: >
+ Example: >vim
" Only one window in the tab page
- :echo winlayout()
+ echo winlayout()
+ < >
['leaf', 1000]
+ < >vim
" Two horizontally split windows
- :echo winlayout()
+ echo winlayout()
+ < >
['col', [['leaf', 1000], ['leaf', 1001]]]
+ < >vim
" The second tab page, with three horizontally split
" windows, with two vertically split windows in the
" middle window
- :echo winlayout(2)
+ echo winlayout(2)
+ < >
['col', [['leaf', 1002], ['row', [['leaf', 1003],
['leaf', 1001]]], ['leaf', 1000]]]
<
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetTabnr()->winlayout()
<
]=],
@@ -13221,12 +13196,12 @@ M.funcs = {
|:wincmd|.
When {arg} is invalid an error is given and zero is returned.
Also see |tabpagewinnr()| and |win_getid()|.
- Examples: >
+ Examples: >vim
let window_count = winnr('$')
let prev_window = winnr('#')
let wnum = winnr('3k')
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetWinval()->winnr()
<
]=],
@@ -13240,10 +13215,10 @@ M.funcs = {
the current window sizes. Only works properly when no windows
are opened or closed and the current window and tab page is
unchanged.
- Example: >
- :let cmd = winrestcmd()
- :call MessWithWindowSizes()
- :exe cmd
+ Example: >vim
+ let cmd = winrestcmd()
+ call MessWithWindowSizes()
+ exe cmd
<
]=],
name = 'winrestcmd',
@@ -13258,8 +13233,8 @@ M.funcs = {
the view of the current window.
Note: The {dict} does not have to contain all values, that are
returned by |winsaveview()|. If values are missing, those
- settings won't be restored. So you can use: >
- :call winrestview({'curswant': 4})
+ settings won't be restored. So you can use: >vim
+ call winrestview({'curswant': 4})
<
This will only set the curswant value (the column the cursor
wants to move on vertical movements) of the cursor to column 5
@@ -13269,7 +13244,7 @@ M.funcs = {
If you have changed the values the result is unpredictable.
If the window size changed the result won't be the same.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetView()->winrestview()
<
]=],
@@ -13318,17 +13293,17 @@ M.funcs = {
When {nr} is zero, the width of the current window is
returned. When window {nr} doesn't exist, -1 is returned.
An existing window always has a width of zero or more.
- Examples: >
- :echo "The current window has " .. winwidth(0) .. " columns."
- :if winwidth(0) <= 50
- : 50 wincmd |
- :endif
+ Examples: >vim
+ echo "The current window has " .. winwidth(0) .. " columns."
+ if winwidth(0) <= 50
+ 50 wincmd |
+ endif
<For getting the terminal or screen size, see the 'columns'
option.
- Can also be used as a |method|: >
+ Can also be used as a |method|: >vim
GetWinid()->winwidth()
-
+ <
]=],
name = 'winwidth',
params = { { 'nr', 'integer' } },
@@ -13380,13 +13355,13 @@ M.funcs = {
last list item. An empty item at the end does cause the
last line in the file to end in a NL.
- 'a' Append mode is used, lines are appended to the file: >
- :call writefile(["foo"], "event.log", "a")
- :call writefile(["bar"], "event.log", "a")
+ 'a' Append mode is used, lines are appended to the file: >vim
+ call writefile(["foo"], "event.log", "a")
+ call writefile(["bar"], "event.log", "a")
<
'D' Delete the file when the current function ends. This
- works like: >
- :defer delete({fname})
+ works like: >vim
+ defer delete({fname})
< Fails when not in a function. Also see |:defer|.
's' fsync() is called after writing the file. This flushes
@@ -13405,13 +13380,13 @@ M.funcs = {
fails.
Also see |readfile()|.
- To copy a file byte for byte: >
- :let fl = readfile("foo", "b")
- :call writefile(fl, "foocopy", "b")
+ To copy a file byte for byte: >vim
+ let fl = readfile("foo", "b")
+ call writefile(fl, "foocopy", "b")
- <Can also be used as a |method|: >
+ <Can also be used as a |method|: >vim
GetText()->writefile("thefile")
-
+ <
]=],
name = 'writefile',
params = { { 'object', 'any' }, { 'fname', 'integer' }, { 'flags', 'string' } },
@@ -13424,11 +13399,11 @@ M.funcs = {
Bitwise XOR on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see `and()` and `or()`.
- Example: >
- :let bits = xor(bits, 0x80)
+ Example: >vim
+ let bits = xor(bits, 0x80)
<
- Can also be used as a |method|: >
- :let bits = bits->xor(0x80)
+ Can also be used as a |method|: >vim
+ let bits = bits->xor(0x80)
<
]=],
name = 'xor',