diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2023-08-01 09:57:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-01 09:57:52 +0100 |
| commit | 9b5f58185e1ff0597c7e95b7205d9ec11be1848c (patch) | |
| tree | 10c93b683b66a0c809f47c891c194c4ca6932f87 /runtime/lua/vim | |
| parent | 12ccea59674602ddf44d6e2394bf9da87b6feeb9 (diff) | |
| download | rneovim-9b5f58185e1ff0597c7e95b7205d9ec11be1848c.tar.gz rneovim-9b5f58185e1ff0597c7e95b7205d9ec11be1848c.tar.bz2 rneovim-9b5f58185e1ff0597c7e95b7205d9ec11be1848c.zip | |
docs(builtin): fix and annotate language blocks (#24506)
Diffstat (limited to 'runtime/lua/vim')
| -rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 2839 |
1 files changed, 1544 insertions, 1295 deletions
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('aฬbฬcฬ', 3) returns 1 ---- echo charidx('aฬbฬcฬ', 6, 1) returns 4 ---- echo charidx('aฬbฬcฬ', 16) returns -1 ---- echo charidx('a๐๐', 4, 0, 1) returns 2 +--- Examples: >vim +--- echo charidx('aฬbฬcฬ', 3) " returns 1 +--- echo charidx('aฬbฬcฬ', 6, 1) " returns 4 +--- echo charidx('aฬbฬcฬ', 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 dig |