eval.lua (491842B)
1 -- File containing table with all functions. 2 -- 3 -- Keys: 4 -- 5 --- @class vim.EvalFn 6 --- @field name? string 7 --- @field args? integer|integer[] Number of arguments, list with maximum and minimum number of arguments 8 --- or list with a minimum number of arguments only. Defaults to zero 9 --- arguments. 10 --- @field base? integer For methods: the argument to use as the base argument (1-indexed): 11 --- base->method() 12 --- Defaults to BASE_NONE (function cannot be used as a method). 13 --- @field func? string Name of the C function which implements the Vimscript function. Defaults to 14 --- `f_{funcname}`. 15 --- @field float_func? string 16 --- @field fast? boolean Function can run in |api-fast| events. Defaults to false. 17 --- @field deprecated? true 18 --- @field returns? string|false 19 --- @field returns_desc? string 20 --- @field generics? string[] Used to write `---@generic` annotations over a function. 21 --- @field signature? string 22 --- @field desc? string 23 --- @field params [string, string, string][] 24 --- @field notes? string[] 25 --- @field see? string[] 26 --- @field lua? false Do not render type information 27 --- @field tags? string[] Extra tags 28 --- @field data? string Used by gen_eval.lua 29 30 -- Usable with the base key: use the last function argument as the method base. 31 -- Value is from funcs.h file. "BASE_" prefix is omitted. 32 -- local LAST = "BASE_LAST" (currently unused after port of v8.2.1168) 33 34 local M = {} 35 36 local VARARGS = { { '...', 'any' } } 37 38 --- @type table<string,vim.EvalFn> 39 M.funcs = { 40 abs = { 41 args = 1, 42 base = 1, 43 desc = [=[ 44 Return the absolute value of {expr}. When {expr} evaluates to 45 a |Float| abs() returns a |Float|. When {expr} can be 46 converted to a |Number| abs() returns a |Number|. Otherwise 47 abs() gives an error message and returns -1. 48 Examples: >vim 49 echo abs(1.456) 50 < 1.456 >vim 51 echo abs(-5.456) 52 < 5.456 >vim 53 echo abs(-4) 54 < 4 55 56 ]=], 57 name = 'abs', 58 params = { { 'expr', 'number' } }, 59 signature = 'abs({expr})', 60 returns = 'number', 61 }, 62 acos = { 63 args = 1, 64 base = 1, 65 desc = [=[ 66 Return the arc cosine of {expr} measured in radians, as a 67 |Float| in the range of [0, pi]. 68 {expr} must evaluate to a |Float| or a |Number| in the range 69 [-1, 1]. 70 Returns NaN if {expr} is outside the range [-1, 1]. Returns 71 0.0 if {expr} is not a |Float| or a |Number|. 72 Examples: >vim 73 echo acos(0) 74 < 1.570796 >vim 75 echo acos(-0.5) 76 < 2.094395 77 78 ]=], 79 float_func = 'acos', 80 name = 'acos', 81 params = { { 'expr', 'number' } }, 82 returns = 'number', 83 signature = 'acos({expr})', 84 }, 85 add = { 86 args = 2, 87 base = 1, 88 desc = [=[ 89 Append the item {expr} to |List| or |Blob| {object}. Returns 90 the resulting |List| or |Blob|. Examples: >vim 91 let alist = add([1, 2, 3], item) 92 call add(mylist, "woodstock") 93 <Note that when {expr} is a |List| it is appended as a single 94 item. Use |extend()| to concatenate |Lists|. 95 When {object} is a |Blob| then {expr} must be a number. 96 Use |insert()| to add an item at another position. 97 Returns 1 if {object} is not a |List| or a |Blob|. 98 99 ]=], 100 name = 'add', 101 params = { { 'object', 'any' }, { 'expr', 'any' } }, 102 returns = 'any', 103 returns_desc = [=[Resulting |List| or |Blob|, or 1 if {object} is not a |List| or a |Blob|.]=], 104 signature = 'add({object}, {expr})', 105 }, 106 ['and'] = { 107 args = 2, 108 base = 1, 109 desc = [=[ 110 Bitwise AND on the two arguments. The arguments are converted 111 to a number. A List, Dict or Float argument causes an error. 112 Also see |or()| and |xor()|. 113 Example: >vim 114 let flag = and(bits, 0x80) 115 < 116 ]=], 117 name = 'and', 118 params = { { 'expr', 'number' }, { 'expr', 'number' } }, 119 returns = 'integer', 120 signature = 'and({expr}, {expr})', 121 }, 122 api_info = { 123 desc = [=[ 124 Returns Dictionary of |api-metadata|. 125 126 View it in a nice human-readable format: >vim 127 lua vim.print(vim.fn.api_info()) 128 < 129 ]=], 130 fast = true, 131 name = 'api_info', 132 params = {}, 133 returns = 'table', 134 signature = 'api_info()', 135 }, 136 append = { 137 args = 2, 138 base = 2, 139 desc = [=[ 140 When {text} is a |List|: Append each item of the |List| as a 141 text line below line {lnum} in the current buffer. 142 Otherwise append {text} as one text line below line {lnum} in 143 the current buffer. 144 Any type of item is accepted and converted to a String. 145 {lnum} can be zero to insert a line before the first one. 146 {lnum} is used like with |getline()|. 147 Returns 1 for failure ({lnum} out of range or out of memory), 148 0 for success. When {text} is an empty list zero is returned, 149 no matter the value of {lnum}. Example: >vim 150 let failed = append(line('$'), "# THE END") 151 let failed = append(0, ["Chapter 1", "the beginning"]) 152 < 153 154 ]=], 155 name = 'append', 156 params = { { 'lnum', 'integer|string' }, { 'text', 'string|string[]' } }, 157 returns = '0|1', 158 signature = 'append({lnum}, {text})', 159 }, 160 appendbufline = { 161 args = 3, 162 base = 3, 163 desc = [=[ 164 Like |append()| but append the text in buffer {expr}. 165 166 This function works only for loaded buffers. First call 167 |bufload()| if needed. 168 169 For the use of {buf}, see |bufname()|. 170 171 {lnum} is the line number to append below. Note that using 172 |line()| would use the current buffer, not the one appending 173 to. Use "$" to append at the end of the buffer. Other string 174 values are not supported. 175 176 On success 0 is returned, on failure 1 is returned. 177 178 If {buf} is not a valid buffer or {lnum} is not valid, an 179 error message is given. Example: >vim 180 let failed = appendbufline(13, 0, "# THE START") 181 <However, when {text} is an empty list then no error is given 182 for an invalid {lnum}, since {lnum} isn't actually used. 183 184 ]=], 185 name = 'appendbufline', 186 params = { { 'buf', 'integer|string' }, { 'lnum', 'integer' }, { 'text', 'string' } }, 187 returns = '0|1', 188 signature = 'appendbufline({buf}, {lnum}, {text})', 189 }, 190 argc = { 191 args = { 0, 1 }, 192 desc = [=[ 193 The result is the number of files in the argument list. See 194 |arglist|. 195 If {winid} is not supplied, the argument list of the current 196 window is used. 197 If {winid} is -1, the global argument list is used. 198 Otherwise {winid} specifies the window of which the argument 199 list is used: either the window number or the window ID. 200 Returns -1 if the {winid} argument is invalid. 201 ]=], 202 name = 'argc', 203 params = { { 'winid', 'integer' } }, 204 returns = 'integer', 205 signature = 'argc([{winid}])', 206 }, 207 argidx = { 208 desc = [=[ 209 The result is the current index in the argument list. 0 is 210 the first file. |argc()| - 1 is the last one. See |arglist|. 211 ]=], 212 name = 'argidx', 213 params = {}, 214 returns = 'integer', 215 signature = 'argidx()', 216 }, 217 arglistid = { 218 args = { 0, 2 }, 219 desc = [=[ 220 Return the argument list ID. This is a number which 221 identifies the argument list being used. Zero is used for the 222 global argument list. See |arglist|. 223 Returns -1 if the arguments are invalid. 224 225 Without arguments use the current window. 226 With {winnr} only use this window in the current tab page. 227 With {winnr} and {tabnr} use the window in the specified tab 228 page. 229 {winnr} can be the window number or the |window-ID|. 230 ]=], 231 name = 'arglistid', 232 params = { { 'winnr', 'integer' }, { 'tabnr', 'integer' } }, 233 returns = 'integer', 234 signature = 'arglistid([{winnr} [, {tabnr}]])', 235 }, 236 argv = { 237 args = { 0, 2 }, 238 desc = [=[ 239 The result is the {nr}th file in the argument list. See 240 |arglist|. "argv(0)" is the first one. Example: >vim 241 let i = 0 242 while i < argc() 243 let f = escape(fnameescape(argv(i)), '.') 244 exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>' 245 let i = i + 1 246 endwhile 247 <Without the {nr} argument, or when {nr} is -1, a |List| with 248 the whole |arglist| is returned. 249 250 The {winid} argument specifies the window ID, see |argc()|. 251 For the Vim command line arguments see |v:argv|. 252 253 Returns an empty string if {nr}th argument is not present in 254 the argument list. Returns an empty List if the {winid} 255 argument is invalid. 256 ]=], 257 name = 'argv', 258 params = { { 'nr', 'integer' }, { 'winid', 'integer' } }, 259 returns = 'string|string[]', 260 signature = 'argv([{nr} [, {winid}]])', 261 }, 262 asin = { 263 args = 1, 264 base = 1, 265 desc = [=[ 266 Return the arc sine of {expr} measured in radians, as a |Float| 267 in the range of [-pi/2, pi/2]. 268 {expr} must evaluate to a |Float| or a |Number| in the range 269 [-1, 1]. 270 Returns NaN if {expr} is outside the range [-1, 1]. Returns 271 0.0 if {expr} is not a |Float| or a |Number|. 272 Examples: >vim 273 echo asin(0.8) 274 < 0.927295 >vim 275 echo asin(-0.5) 276 < -0.523599 277 278 ]=], 279 float_func = 'asin', 280 name = 'asin', 281 params = { { 'expr', 'any' } }, 282 returns = 'number', 283 signature = 'asin({expr})', 284 }, 285 assert_beeps = { 286 args = 1, 287 base = 1, 288 desc = [=[ 289 Run {cmd} and add an error message to |v:errors| if it does 290 NOT produce a beep or visual bell. 291 Also see |assert_fails()|, |assert_nobeep()| and 292 |assert-return|. 293 294 ]=], 295 name = 'assert_beeps', 296 params = { { 'cmd', 'string' } }, 297 returns = '0|1', 298 signature = 'assert_beeps({cmd})', 299 }, 300 assert_equal = { 301 args = { 2, 3 }, 302 base = 2, 303 desc = [=[ 304 When {expected} and {actual} are not equal an error message is 305 added to |v:errors| and 1 is returned. Otherwise zero is 306 returned. |assert-return| 307 The error is in the form "Expected {expected} but got 308 {actual}". When {msg} is present it is prefixed to that, 309 along with the location of the assert when run from a script. 310 311 There is no automatic conversion, the String "4" is different 312 from the Number 4. And the number 4 is different from the 313 Float 4.0. The value of 'ignorecase' is not used here, case 314 always matters. 315 Example: >vim 316 call assert_equal('foo', 'bar', 'baz') 317 <Will add the following to |v:errors|: > 318 test.vim line 12: baz: Expected 'foo' but got 'bar' 319 < 320 ]=], 321 name = 'assert_equal', 322 params = { { 'expected', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, 323 returns = '0|1', 324 signature = 'assert_equal({expected}, {actual} [, {msg}])', 325 }, 326 assert_equalfile = { 327 args = { 2, 3 }, 328 base = 1, 329 desc = [=[ 330 When the files {fname_one} and {fname_two} do not contain 331 exactly the same text an error message is added to |v:errors|. 332 Also see |assert-return|. 333 When {fname_one} or {fname_two} does not exist the error will 334 mention that. 335 336 ]=], 337 name = 'assert_equalfile', 338 params = { { 'fname_one', 'string' }, { 'fname_two', 'string' } }, 339 returns = '0|1', 340 signature = 'assert_equalfile({fname_one}, {fname_two})', 341 }, 342 assert_exception = { 343 args = { 1, 2 }, 344 desc = [=[ 345 When v:exception does not contain the string {error} an error 346 message is added to |v:errors|. Also see |assert-return|. 347 This can be used to assert that a command throws an exception. 348 Using the error number, followed by a colon, avoids problems 349 with translations: >vim 350 try 351 commandthatfails 352 call assert_false(1, 'command should have failed') 353 catch 354 call assert_exception('E492:') 355 endtry 356 < 357 ]=], 358 name = 'assert_exception', 359 params = { { 'error', 'any' }, { 'msg', 'any' } }, 360 returns = '0|1', 361 signature = 'assert_exception({error} [, {msg}])', 362 }, 363 assert_fails = { 364 args = { 1, 5 }, 365 base = 1, 366 desc = [=[ 367 Run {cmd} and add an error message to |v:errors| if it does 368 NOT produce an error or when {error} is not found in the 369 error message. Also see |assert-return|. 370 371 When {error} is a string it must be found literally in the 372 first reported error. Most often this will be the error code, 373 including the colon, e.g. "E123:". >vim 374 call assert_fails('bad cmd', 'E987:') 375 < 376 When {error} is a |List| with one or two strings, these are 377 used as patterns. The first pattern is matched against the 378 first reported error: >vim 379 call assert_fails('cmd', ['E987:.*expected bool']) 380 <The second pattern, if present, is matched against the last 381 reported error. To only match the last error use an empty 382 string for the first error: >vim 383 call assert_fails('cmd', ['', 'E987:']) 384 < 385 If {msg} is empty then it is not used. Do this to get the 386 default message when passing the {lnum} argument. 387 *E1115* 388 When {lnum} is present and not negative, and the {error} 389 argument is present and matches, then this is compared with 390 the line number at which the error was reported. That can be 391 the line number in a function or in a script. 392 *E1116* 393 When {context} is present it is used as a pattern and matched 394 against the context (script name or function name) where 395 {lnum} is located in. 396 397 Note that beeping is not considered an error, and some failing 398 commands only beep. Use |assert_beeps()| for those. 399 400 ]=], 401 name = 'assert_fails', 402 params = { 403 { 'cmd', 'string' }, 404 { 'error', 'any' }, 405 { 'msg', 'any' }, 406 { 'lnum', 'integer' }, 407 { 'context', 'any' }, 408 }, 409 returns = '0|1', 410 signature = 'assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])', 411 }, 412 assert_false = { 413 args = { 1, 2 }, 414 base = 1, 415 desc = [=[ 416 When {actual} is not false an error message is added to 417 |v:errors|, like with |assert_equal()|. 418 The error is in the form "Expected False but got {actual}". 419 When {msg} is present it is prefixed to that, along with the 420 location of the assert when run from a script. 421 Also see |assert-return|. 422 423 A value is false when it is zero. When {actual} is not a 424 number the assert fails. 425 426 ]=], 427 name = 'assert_false', 428 params = { { 'actual', 'any' }, { 'msg', 'any' } }, 429 returns = '0|1', 430 signature = 'assert_false({actual} [, {msg}])', 431 }, 432 assert_inrange = { 433 args = { 3, 4 }, 434 base = 3, 435 desc = [=[ 436 This asserts number and |Float| values. When {actual} is lower 437 than {lower} or higher than {upper} an error message is added 438 to |v:errors|. Also see |assert-return|. 439 The error is in the form "Expected range {lower} - {upper}, 440 but got {actual}". When {msg} is present it is prefixed to 441 that. 442 ]=], 443 name = 'assert_inrange', 444 params = { 445 { 'lower', 'number' }, 446 { 'upper', 'number' }, 447 { 'actual', 'number' }, 448 { 'msg', 'string' }, 449 }, 450 returns = '0|1', 451 signature = 'assert_inrange({lower}, {upper}, {actual} [, {msg}])', 452 }, 453 assert_match = { 454 args = { 2, 3 }, 455 base = 2, 456 desc = [=[ 457 When {pattern} does not match {actual} an error message is 458 added to |v:errors|. Also see |assert-return|. 459 The error is in the form "Pattern {pattern} does not match 460 {actual}". When {msg} is present it is prefixed to that, 461 along with the location of the assert when run from a script. 462 463 {pattern} is used as with |expr-=~|: The matching is always done 464 like 'magic' was set and 'cpoptions' is empty, no matter what 465 the actual value of 'magic' or 'cpoptions' is. 466 467 {actual} is used as a string, automatic conversion applies. 468 Use "^" and "$" to match with the start and end of the text. 469 Use both to match the whole text. 470 471 Example: >vim 472 call assert_match('^f.*o$', 'foobar') 473 <Will result in a string to be added to |v:errors|: > 474 test.vim line 12: Pattern '^f.*o$' does not match 'foobar' 475 < 476 ]=], 477 name = 'assert_match', 478 params = { { 'pattern', 'string' }, { 'actual', 'string' }, { 'msg', 'string' } }, 479 returns = '0|1', 480 signature = 'assert_match({pattern}, {actual} [, {msg}])', 481 }, 482 assert_nobeep = { 483 args = 1, 484 base = 1, 485 desc = [=[ 486 Run {cmd} and add an error message to |v:errors| if it 487 produces a beep or visual bell. 488 Also see |assert_beeps()|. 489 490 ]=], 491 name = 'assert_nobeep', 492 params = { { 'cmd', 'string' } }, 493 returns = '0|1', 494 signature = 'assert_nobeep({cmd})', 495 }, 496 assert_notequal = { 497 args = { 2, 3 }, 498 base = 2, 499 desc = [=[ 500 The opposite of `assert_equal()`: add an error message to 501 |v:errors| when {expected} and {actual} are equal. 502 Also see |assert-return|. 503 504 ]=], 505 name = 'assert_notequal', 506 params = { { 'expected', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, 507 returns = '0|1', 508 signature = 'assert_notequal({expected}, {actual} [, {msg}])', 509 }, 510 assert_notmatch = { 511 args = { 2, 3 }, 512 base = 2, 513 desc = [=[ 514 The opposite of `assert_match()`: add an error message to 515 |v:errors| when {pattern} matches {actual}. 516 Also see |assert-return|. 517 518 ]=], 519 name = 'assert_notmatch', 520 params = { { 'pattern', 'string' }, { 'actual', 'string' }, { 'msg', 'string' } }, 521 returns = '0|1', 522 signature = 'assert_notmatch({pattern}, {actual} [, {msg}])', 523 }, 524 assert_report = { 525 args = 1, 526 base = 1, 527 desc = [=[ 528 Report a test failure directly, using String {msg}. 529 Always returns one. 530 531 ]=], 532 name = 'assert_report', 533 params = { { 'msg', 'string' } }, 534 returns = '0|1', 535 signature = 'assert_report({msg})', 536 }, 537 assert_true = { 538 args = { 1, 2 }, 539 base = 1, 540 desc = [=[ 541 When {actual} is not true an error message is added to 542 |v:errors|, like with |assert_equal()|. 543 Also see |assert-return|. 544 A value is |TRUE| when it is a non-zero number or |v:true|. 545 When {actual} is not a number or |v:true| the assert fails. 546 When {msg} is given it is prefixed to the default message, 547 along with the location of the assert when run from a script. 548 549 ]=], 550 name = 'assert_true', 551 params = { { 'actual', 'any' }, { 'msg', 'string' } }, 552 returns = '0|1', 553 signature = 'assert_true({actual} [, {msg}])', 554 }, 555 atan = { 556 args = 1, 557 base = 1, 558 desc = [=[ 559 Return the principal value of the arc tangent of {expr}, in 560 the range [-pi/2, +pi/2] radians, as a |Float|. 561 {expr} must evaluate to a |Float| or a |Number|. 562 Returns 0.0 if {expr} is not a |Float| or a |Number|. 563 Examples: >vim 564 echo atan(100) 565 < 1.560797 >vim 566 echo atan(-4.01) 567 < -1.326405 568 569 ]=], 570 float_func = 'atan', 571 name = 'atan', 572 params = { { 'expr', 'number' } }, 573 returns = 'number', 574 signature = 'atan({expr})', 575 }, 576 atan2 = { 577 args = 2, 578 base = 1, 579 desc = [=[ 580 Return the arc tangent of {expr1} / {expr2}, measured in 581 radians, as a |Float| in the range [-pi, pi]. 582 {expr1} and {expr2} must evaluate to a |Float| or a |Number|. 583 Returns 0.0 if {expr1} or {expr2} is not a |Float| or a 584 |Number|. 585 Examples: >vim 586 echo atan2(-1, 1) 587 < -0.785398 >vim 588 echo atan2(1, -1) 589 < 2.356194 590 591 ]=], 592 name = 'atan2', 593 params = { { 'expr1', 'number' }, { 'expr2', 'number' } }, 594 returns = 'number', 595 signature = 'atan2({expr1}, {expr2})', 596 }, 597 blob2list = { 598 args = 1, 599 base = 1, 600 desc = [=[ 601 Return a List containing the number value of each byte in Blob 602 {blob}. Examples: >vim 603 blob2list(0z0102.0304) " returns [1, 2, 3, 4] 604 blob2list(0z) " returns [] 605 <Returns an empty List on error. |list2blob()| does the 606 opposite. 607 608 ]=], 609 name = 'blob2list', 610 params = { { 'blob', 'any' } }, 611 returns = 'any[]', 612 signature = 'blob2list({blob})', 613 }, 614 browse = { 615 args = 4, 616 desc = [=[ 617 Put up a file requester. This only works when "has("browse")" 618 returns |TRUE| (only in some GUI versions). 619 The input fields are: 620 {save} when |TRUE|, select file to write 621 {title} title for the requester 622 {initdir} directory to start browsing in 623 {default} default file name 624 An empty string is returned when the "Cancel" button is hit, 625 something went wrong, or browsing is not possible. 626 ]=], 627 name = 'browse', 628 params = { 629 { 'save', 'any' }, 630 { 'title', 'string' }, 631 { 'initdir', 'string' }, 632 { 'default', 'string' }, 633 }, 634 returns = '0|1', 635 signature = 'browse({save}, {title}, {initdir}, {default})', 636 }, 637 browsedir = { 638 args = 2, 639 desc = [=[ 640 Put up a directory requester. This only works when 641 "has("browse")" returns |TRUE| (only in some GUI versions). 642 On systems where a directory browser is not supported a file 643 browser is used. In that case: select a file in the directory 644 to be used. 645 The input fields are: 646 {title} title for the requester 647 {initdir} directory to start browsing in 648 When the "Cancel" button is hit, something went wrong, or 649 browsing is not possible, an empty string is returned. 650 ]=], 651 name = 'browsedir', 652 params = { { 'title', 'string' }, { 'initdir', 'string' } }, 653 returns = '0|1', 654 signature = 'browsedir({title}, {initdir})', 655 }, 656 bufadd = { 657 args = 1, 658 base = 1, 659 desc = [=[ 660 Add a buffer to the buffer list with name {name} (must be a 661 String). 662 If a buffer for file {name} already exists, return that buffer 663 number. Otherwise return the buffer number of the newly 664 created buffer. When {name} is an empty string then a new 665 buffer is always created. 666 The buffer will not have 'buflisted' set and not be loaded 667 yet. To add some text to the buffer use this: >vim 668 let bufnr = bufadd('someName') 669 call bufload(bufnr) 670 call setbufline(bufnr, 1, ['some', 'text']) 671 <Returns 0 on error. 672 ]=], 673 name = 'bufadd', 674 params = { { 'name', 'string' } }, 675 returns = 'integer', 676 signature = 'bufadd({name})', 677 }, 678 bufexists = { 679 args = 1, 680 base = 1, 681 desc = [=[ 682 The result is a Number, which is |TRUE| if a buffer called 683 {buf} exists. 684 If the {buf} argument is a number, buffer numbers are used. 685 Number zero is the alternate buffer for the current window. 686 687 If the {buf} argument is a string it must match a buffer name 688 exactly. The name can be: 689 - Relative to the current directory. 690 - A full path. 691 - The name of a buffer with 'buftype' set to "nofile". 692 - A URL name. 693 Unlisted buffers will be found. 694 Note that help files are listed by their short name in the 695 output of |:buffers|, but bufexists() requires using their 696 long name to be able to find them. 697 bufexists() may report a buffer exists, but to use the name 698 with a |:buffer| command you may need to use |expand()|. Esp 699 for MS-Windows 8.3 names in the form "c:\DOCUME~1" 700 Use "bufexists(0)" to test for the existence of an alternate 701 file name. 702 703 ]=], 704 name = 'bufexists', 705 params = { { 'buf', 'any' } }, 706 returns = '0|1', 707 signature = 'bufexists({buf})', 708 }, 709 buffer_exists = { 710 args = 1, 711 base = 1, 712 deprecated = true, 713 desc = [=[ 714 Obsolete name for |bufexists()|. 715 ]=], 716 func = 'f_bufexists', 717 name = 'buffer_exists', 718 params = VARARGS, 719 returns = '0|1', 720 signature = 'buffer_exists({buf})', 721 }, 722 buffer_name = { 723 args = { 0, 1 }, 724 base = 1, 725 deprecated = true, 726 desc = [=[ 727 Obsolete name for |bufname()|. 728 ]=], 729 func = 'f_bufname', 730 name = 'buffer_name', 731 params = VARARGS, 732 returns = 'string', 733 signature = 'buffer_name([{buf}])', 734 }, 735 buffer_number = { 736 args = { 0, 1 }, 737 base = 1, 738 deprecated = true, 739 desc = [=[ 740 Obsolete name for |bufnr()|. 741 ]=], 742 func = 'f_bufnr', 743 name = 'buffer_number', 744 params = VARARGS, 745 returns = 'integer', 746 signature = 'buffer_number([{buf} [, {create}]])', 747 }, 748 buflisted = { 749 args = 1, 750 base = 1, 751 desc = [=[ 752 The result is a Number, which is |TRUE| if a buffer called 753 {buf} exists and is listed (has the 'buflisted' option set). 754 The {buf} argument is used like with |bufexists()|. 755 756 ]=], 757 name = 'buflisted', 758 params = { { 'buf', 'any' } }, 759 returns = '0|1', 760 signature = 'buflisted({buf})', 761 }, 762 bufload = { 763 args = 1, 764 base = 1, 765 desc = [=[ 766 Ensure the buffer {buf} is loaded. When the buffer name 767 refers to an existing file then the file is read. Otherwise 768 the buffer will be empty. If the buffer was already loaded 769 then there is no change. If the buffer is not related to a 770 file then no file is read (e.g., when 'buftype' is "nofile"). 771 If there is an existing swap file for the file of the buffer, 772 there will be no dialog, the buffer will be loaded anyway. 773 The {buf} argument is used like with |bufexists()|. 774 775 ]=], 776 name = 'bufload', 777 params = { { 'buf', 'any' } }, 778 returns = false, 779 signature = 'bufload({buf})', 780 }, 781 bufloaded = { 782 args = 1, 783 base = 1, 784 desc = [=[ 785 The result is a Number, which is |TRUE| if a buffer called 786 {buf} exists and is loaded (shown in a window or hidden). 787 The {buf} argument is used like with |bufexists()|. 788 789 ]=], 790 name = 'bufloaded', 791 params = { { 'buf', 'any' } }, 792 returns = '0|1', 793 signature = 'bufloaded({buf})', 794 }, 795 bufname = { 796 args = { 0, 1 }, 797 base = 1, 798 desc = [=[ 799 The result is the name of a buffer. Mostly as it is displayed 800 by the `:ls` command, but not using special names such as 801 "[No Name]". 802 If {buf} is omitted the current buffer is used. 803 If {buf} is a Number, that buffer number's name is given. 804 Number zero is the alternate buffer for the current window. 805 If {buf} is a String, it is used as a |file-pattern| to match 806 with the buffer names. This is always done like 'magic' is 807 set and 'cpoptions' is empty. When there is more than one 808 match an empty string is returned. 809 "" or "%" can be used for the current buffer, "#" for the 810 alternate buffer. 811 A full match is preferred, otherwise a match at the start, end 812 or middle of the buffer name is accepted. If you only want a 813 full match then put "^" at the start and "$" at the end of the 814 pattern. 815 Listed buffers are found first. If there is a single match 816 with a listed buffer, that one is returned. Next unlisted 817 buffers are searched for. 818 If the {buf} is a String, but you want to use it as a buffer 819 number, force it to be a Number by adding zero to it: >vim 820 echo bufname("3" + 0) 821 <If the buffer doesn't exist, or doesn't have a name, an empty 822 string is returned. >vim 823 echo bufname("#") " alternate buffer name 824 echo bufname(3) " name of buffer 3 825 echo bufname("%") " name of current buffer 826 echo bufname("file2") " name of buffer where "file2" matches. 827 < 828 ]=], 829 name = 'bufname', 830 params = { { 'buf', 'integer|string' } }, 831 returns = 'string', 832 signature = 'bufname([{buf}])', 833 }, 834 bufnr = { 835 args = { 0, 2 }, 836 base = 1, 837 desc = [=[ 838 The result is the number of a buffer, as it is displayed by 839 the `:ls` command. For the use of {buf}, see |bufname()| 840 above. 841 If the buffer doesn't exist, -1 is returned. Or, if the 842 {create} argument is present and TRUE, a new, unlisted, 843 buffer is created and its number is returned. Example: >vim 844 let newbuf = bufnr('Scratch001', 1) 845 <Using an empty name uses the current buffer. To create a new 846 buffer with an empty name use |bufadd()|. 847 848 bufnr("$") is the last buffer: >vim 849 let last_buffer = bufnr("$") 850 <The result is a Number, which is the highest buffer number 851 of existing buffers. Note that not all buffers with a smaller 852 number necessarily exist, because ":bwipeout" may have removed 853 them. Use |bufexists()| to test for the existence of a buffer. 854 855 ]=], 856 name = 'bufnr', 857 params = { { 'buf', 'integer|string' }, { 'create', 'any' } }, 858 returns = 'integer', 859 signature = 'bufnr([{buf} [, {create}]])', 860 }, 861 bufwinid = { 862 args = 1, 863 base = 1, 864 desc = [=[ 865 The result is a Number, which is the |window-ID| of the first 866 window associated with buffer {buf}. For the use of {buf}, 867 see |bufname()| above. If buffer {buf} doesn't exist or 868 there is no such window, -1 is returned. Example: >vim 869 870 echo "A window containing buffer 1 is " .. (bufwinid(1)) 871 < 872 Only deals with the current tab page. See |win_findbuf()| for 873 finding more. 874 875 ]=], 876 name = 'bufwinid', 877 params = { { 'buf', 'any' } }, 878 returns = 'integer', 879 signature = 'bufwinid({buf})', 880 }, 881 bufwinnr = { 882 args = 1, 883 base = 1, 884 desc = [=[ 885 Like |bufwinid()| but return the window number instead of the 886 |window-ID|. 887 If buffer {buf} doesn't exist or there is no such window, -1 888 is returned. Example: >vim 889 890 echo "A window containing buffer 1 is " .. (bufwinnr(1)) 891 892 <The number can be used with |CTRL-W_w| and ":wincmd w" 893 |:wincmd|. 894 895 ]=], 896 name = 'bufwinnr', 897 params = { { 'buf', 'any' } }, 898 returns = 'integer', 899 signature = 'bufwinnr({buf})', 900 }, 901 byte2line = { 902 args = 1, 903 base = 1, 904 desc = [=[ 905 Return the line number that contains the character at byte 906 count {byte} in the current buffer. This includes the 907 end-of-line character, depending on the 'fileformat' option 908 for the current buffer. The first character has byte count 909 one. 910 Also see |line2byte()|, |go| and |:goto|. 911 912 Returns -1 if the {byte} value is invalid. 913 914 ]=], 915 name = 'byte2line', 916 params = { { 'byte', 'any' } }, 917 returns = 'integer', 918 signature = 'byte2line({byte})', 919 }, 920 byteidx = { 921 args = { 2, 3 }, 922 base = 1, 923 desc = [=[ 924 Return byte index of the {nr}th character in the String 925 {expr}. Use zero for the first character, it then returns 926 zero. 927 If there are no multibyte characters the returned value is 928 equal to {nr}. 929 Composing characters are not counted separately, their byte 930 length is added to the preceding base character. See 931 |byteidxcomp()| below for counting composing characters 932 separately. 933 When {utf16} is present and TRUE, {nr} is used as the UTF-16 934 index in the String {expr} instead of as the character index. 935 The UTF-16 index is the index in the string when it is encoded 936 with 16-bit words. If the specified UTF-16 index is in the 937 middle of a character (e.g. in a 4-byte character), then the 938 byte index of the first byte in the character is returned. 939 Refer to |string-offset-encoding| for more information. 940 Example : >vim 941 echo matchstr(str, ".", byteidx(str, 3)) 942 <will display the fourth character. Another way to do the 943 same: >vim 944 let s = strpart(str, byteidx(str, 3)) 945 echo strpart(s, 0, byteidx(s, 1)) 946 <Also see |strgetchar()| and |strcharpart()|. 947 948 If there are less than {nr} characters -1 is returned. 949 If there are exactly {nr} characters the length of the string 950 in bytes is returned. 951 See |charidx()| and |utf16idx()| for getting the character and 952 UTF-16 index respectively from the byte index. 953 Examples: >vim 954 echo byteidx('a😊😊', 2) " returns 5 955 echo byteidx('a😊😊', 2, 1) " returns 1 956 echo byteidx('a😊😊', 3, 1) " returns 5 957 < 958 ]=], 959 fast = true, 960 name = 'byteidx', 961 params = { { 'expr', 'any' }, { 'nr', 'integer' }, { 'utf16', 'any' } }, 962 returns = 'integer', 963 signature = 'byteidx({expr}, {nr} [, {utf16}])', 964 }, 965 byteidxcomp = { 966 args = { 2, 3 }, 967 base = 1, 968 desc = [=[ 969 Like |byteidx()|, except that a composing character is counted 970 as a separate character. Example: >vim 971 let s = 'e' .. nr2char(0x301) 972 echo byteidx(s, 1) 973 echo byteidxcomp(s, 1) 974 echo byteidxcomp(s, 2) 975 <The first and third echo result in 3 ('e' plus composing 976 character is 3 bytes), the second echo results in 1 ('e' is 977 one byte). 978 979 ]=], 980 fast = true, 981 name = 'byteidxcomp', 982 params = { { 'expr', 'any' }, { 'nr', 'integer' }, { 'utf16', 'any' } }, 983 returns = 'integer', 984 signature = 'byteidxcomp({expr}, {nr} [, {utf16}])', 985 }, 986 call = { 987 args = { 2, 3 }, 988 base = 1, 989 desc = [=[ 990 Call function {func} with the items in |List| {arglist} as 991 arguments. 992 {func} can either be a |Funcref| or the name of a function. 993 a:firstline and a:lastline are set to the cursor line. 994 Returns the return value of the called function. 995 {dict} is for functions with the "dict" attribute. It will be 996 used to set the local variable "self". |Dictionary-function| 997 998 ]=], 999 name = 'call', 1000 params = { { 'func', 'any' }, { 'arglist', 'any' }, { 'dict', 'any' } }, 1001 returns = 'any', 1002 signature = 'call({func}, {arglist} [, {dict}])', 1003 tags = { 'E699' }, 1004 }, 1005 ceil = { 1006 args = 1, 1007 base = 1, 1008 desc = [=[ 1009 Return the smallest integral value greater than or equal to 1010 {expr} as a |Float| (round up). 1011 {expr} must evaluate to a |Float| or a |Number|. 1012 Examples: >vim 1013 echo ceil(1.456) 1014 < 2.0 >vim 1015 echo ceil(-5.456) 1016 < -5.0 >vim 1017 echo ceil(4.0) 1018 < 4.0 1019 1020 Returns 0.0 if {expr} is not a |Float| or a |Number|. 1021 1022 ]=], 1023 float_func = 'ceil', 1024 name = 'ceil', 1025 params = { { 'expr', 'number' } }, 1026 returns = 'number', 1027 signature = 'ceil({expr})', 1028 }, 1029 chanclose = { 1030 args = { 1, 2 }, 1031 desc = [=[ 1032 Close a channel or a specific stream associated with it. 1033 For a job, {stream} can be one of "stdin", "stdout", 1034 "stderr" or "rpc" (closes stdin/stdout for a job started 1035 with `"rpc":v:true`) If {stream} is omitted, all streams 1036 are closed. If the channel is a pty, this will then close the 1037 pty master, sending SIGHUP to the job process. 1038 For a socket, there is only one stream, and {stream} should be 1039 omitted. 1040 ]=], 1041 name = 'chanclose', 1042 params = { { 'id', 'integer' }, { 'stream', 'string' } }, 1043 returns = '0|1', 1044 signature = 'chanclose({id} [, {stream}])', 1045 }, 1046 changenr = { 1047 desc = [=[ 1048 Return the number of the most recent change. This is the same 1049 number as what is displayed with |:undolist| and can be used 1050 with the |:undo| command. 1051 When a change was made it is the number of that change. After 1052 redo it is the number of the redone change. After undo it is 1053 one less than the number of the undone change. 1054 Returns 0 if the undo list is empty. 1055 ]=], 1056 name = 'changenr', 1057 params = {}, 1058 returns = 'integer', 1059 signature = 'changenr()', 1060 }, 1061 chansend = { 1062 args = 2, 1063 desc = [=[ 1064 Send data to channel {id}. For a job, it writes it to the 1065 stdin of the process. For the stdio channel |channel-stdio|, 1066 it writes to Nvim's stdout. Returns the number of bytes 1067 written if the write succeeded, 0 otherwise. 1068 See |channel-bytes| for more information. 1069 1070 {data} may be a string, string convertible, |Blob|, or a list. 1071 If {data} is a list, the items will be joined by newlines; any 1072 newlines in an item will be sent as NUL. To send a final 1073 newline, include a final empty string. Example: >vim 1074 call chansend(id, ["abc", "123\n456", ""]) 1075 <will send "abc<NL>123<NUL>456<NL>". 1076 1077 chansend() writes raw data, not RPC messages. If the channel 1078 was created with `"rpc":v:true` then the channel expects RPC 1079 messages, use |rpcnotify()| and |rpcrequest()| instead. 1080 ]=], 1081 name = 'chansend', 1082 params = { { 'id', 'number' }, { 'data', 'string|string[]' } }, 1083 returns = '0|1', 1084 signature = 'chansend({id}, {data})', 1085 }, 1086 char2nr = { 1087 args = { 1, 2 }, 1088 base = 1, 1089 desc = [=[ 1090 Return Number value of the first char in {string}. 1091 Examples: >vim 1092 echo char2nr(" ") " returns 32 1093 echo char2nr("ABC") " returns 65 1094 echo char2nr("á") " returns 225 1095 echo char2nr("á"[0]) " returns 195 1096 echo char2nr("\<M-x>") " returns 128 1097 <Non-ASCII characters are always treated as UTF-8 characters. 1098 {utf8} is ignored, it exists only for backwards-compatibility. 1099 A combining character is a separate character. 1100 |nr2char()| does the opposite. 1101 1102 Returns 0 if {string} is not a |String|. 1103 1104 ]=], 1105 fast = true, 1106 name = 'char2nr', 1107 params = { { 'string', 'string' }, { 'utf8', 'any' } }, 1108 returns = '0|1', 1109 signature = 'char2nr({string} [, {utf8}])', 1110 }, 1111 charclass = { 1112 args = 1, 1113 base = 1, 1114 desc = [=[ 1115 Return the character class of the first character in {string}. 1116 The character class is one of: 1117 0 blank 1118 1 punctuation 1119 2 word character (depends on 'iskeyword') 1120 3 emoji 1121 other specific Unicode class 1122 The class is used in patterns and word motions. 1123 Returns 0 if {string} is not a |String|. 1124 ]=], 1125 name = 'charclass', 1126 params = { { 'string', 'string' } }, 1127 returns = "0|1|2|3|'other'", 1128 signature = 'charclass({string})', 1129 }, 1130 charcol = { 1131 args = { 1, 2 }, 1132 base = 1, 1133 desc = [=[ 1134 Same as |col()| but returns the character index of the column 1135 position given with {expr} instead of the byte position. 1136 1137 Example: 1138 With the cursor on '세' in line 5 with text "여보세요": >vim 1139 echo charcol('.') " returns 3 1140 echo col('.') " returns 7 1141 < 1142 1143 ]=], 1144 name = 'charcol', 1145 params = { { 'expr', 'string|any[]' }, { 'winid', 'integer' } }, 1146 returns = 'integer', 1147 signature = 'charcol({expr} [, {winid}])', 1148 }, 1149 charidx = { 1150 args = { 2, 4 }, 1151 base = 1, 1152 desc = [=[ 1153 Return the character index of the byte at {idx} in {string}. 1154 The index of the first character is zero. 1155 If there are no multibyte characters the returned value is 1156 equal to {idx}. 1157 1158 When {countcc} is omitted or |FALSE|, then composing characters 1159 are not counted separately, their byte length is added to the 1160 preceding base character. 1161 When {countcc} is |TRUE|, then composing characters are 1162 counted as separate characters. 1163 1164 When {utf16} is present and TRUE, {idx} is used as the UTF-16 1165 index in the String {expr} instead of as the byte index. 1166 1167 Returns -1 if the arguments are invalid or if there are less 1168 than {idx} bytes. If there are exactly {idx} bytes the length 1169 of the string in characters is returned. 1170 1171 An error is given and -1 is returned if the first argument is 1172 not a string, the second argument is not a number or when the 1173 third argument is present and is not zero or one. 1174 1175 See |byteidx()| and |byteidxcomp()| for getting the byte index 1176 from the character index and |utf16idx()| for getting the 1177 UTF-16 index from the character index. 1178 Refer to |string-offset-encoding| for more information. 1179 Examples: >vim 1180 echo charidx('áb́ć', 3) " returns 1 1181 echo charidx('áb́ć', 6, 1) " returns 4 1182 echo charidx('áb́ć', 16) " returns -1 1183 echo charidx('a😊😊', 4, 0, 1) " returns 2 1184 < 1185 ]=], 1186 name = 'charidx', 1187 params = { 1188 { 'string', 'string' }, 1189 { 'idx', 'integer' }, 1190 { 'countcc', 'boolean' }, 1191 { 'utf16', 'boolean' }, 1192 }, 1193 returns = 'integer', 1194 signature = 'charidx({string}, {idx} [, {countcc} [, {utf16}]])', 1195 }, 1196 chdir = { 1197 args = { 1, 2 }, 1198 base = 1, 1199 desc = [=[ 1200 Changes the current working directory to {dir}. The scope of 1201 the change is determined as follows: 1202 If {scope} is not present, the current working directory is 1203 changed to the scope of the current directory: 1204 - If the window local directory (|:lcd|) is set, it 1205 changes the current working directory for that scope. 1206 - Otherwise, if the tab page local directory (|:tcd|) is 1207 set, it changes the current directory for that scope. 1208 - Otherwise, changes the global directory for that scope. 1209 1210 If {scope} is present, changes the current working directory 1211 for the specified scope: 1212 "window" Changes the window local directory. |:lcd| 1213 "tabpage" Changes the tab page local directory. |:tcd| 1214 "global" Changes the global directory. |:cd| 1215 1216 {dir} must be a String. 1217 If successful, returns the previous working directory. Pass 1218 this to another chdir() to restore the directory. 1219 On failure, returns an empty string. 1220 1221 Example: >vim 1222 let save_dir = chdir(newdir) 1223 if save_dir != "" 1224 " ... do some work 1225 call chdir(save_dir) 1226 endif 1227 < 1228 1229 ]=], 1230 name = 'chdir', 1231 params = { { 'dir', 'string' }, { 'scope', 'string' } }, 1232 returns = 'string', 1233 signature = 'chdir({dir} [, {scope}])', 1234 }, 1235 cindent = { 1236 args = 1, 1237 base = 1, 1238 desc = [=[ 1239 Get the amount of indent for line {lnum} according the 1240 |C-indenting| rules, as with 'cindent'. 1241 The indent is counted in spaces, the value of 'tabstop' is 1242 relevant. {lnum} is used just like in |getline()|. 1243 When {lnum} is invalid -1 is returned. 1244 1245 To get or set indent of lines in a string, see |vim.text.indent()|. 1246 1247 ]=], 1248 name = 'cindent', 1249 params = { { 'lnum', 'integer|string' } }, 1250 returns = 'integer', 1251 signature = 'cindent({lnum})', 1252 }, 1253 clearmatches = { 1254 args = { 0, 1 }, 1255 base = 1, 1256 desc = [=[ 1257 Clears all matches previously defined for the current window 1258 by |matchadd()| and the |:match| commands. 1259 If {win} is specified, use the window with this number or 1260 window ID instead of the current window. 1261 1262 ]=], 1263 name = 'clearmatches', 1264 params = { { 'win', 'integer' } }, 1265 returns = false, 1266 signature = 'clearmatches([{win}])', 1267 }, 1268 cmdcomplete_info = { 1269 args = 0, 1270 desc = [=[ 1271 Returns a |Dictionary| with information about cmdline 1272 completion. See |cmdline-completion|. 1273 The items are: 1274 cmdline_orig The original command-line string before 1275 completion began. 1276 pum_visible |TRUE| if popup menu is visible. 1277 See |pumvisible()|. 1278 matches List of all completion candidates. Each item 1279 is a string. 1280 selected Selected item index. First index is zero. 1281 Index is -1 if no item is selected (showing 1282 typed text only, or the last completion after 1283 no item is selected when using the <Up> or 1284 <Down> keys) 1285 1286 Returns an empty |Dictionary| if no completion was attempted, 1287 if there was only one candidate and it was fully completed, or 1288 if an error occurred. 1289 ]=], 1290 name = 'cmdcomplete_info', 1291 params = {}, 1292 returns = 'table<string,any>', 1293 signature = 'cmdcomplete_info()', 1294 }, 1295 col = { 1296 args = { 1, 2 }, 1297 base = 1, 1298 desc = [=[ 1299 The result is a Number, which is the byte index of the column 1300 position given with {expr}. 1301 For accepted positions see |getpos()|. 1302 When {expr} is "$", it means the end of the cursor line, so 1303 the result is the number of bytes in the cursor line plus one. 1304 Additionally {expr} can be [lnum, col]: a |List| with the line 1305 and column number. Most useful when the column is "$", to get 1306 the last column of a specific line. When "lnum" or "col" is 1307 out of range then col() returns zero. 1308 1309 With the optional {winid} argument the values are obtained for 1310 that window instead of the current window. 1311 1312 To get the line number use |line()|. To get both use 1313 |getpos()|. 1314 1315 For the screen column position use |virtcol()|. For the 1316 character position use |charcol()|. 1317 1318 Note that only marks in the current file can be used. 1319 1320 Examples: >vim 1321 echo col(".") " column of cursor 1322 echo col("$") " length of cursor line plus one 1323 echo col("'t") " column of mark t 1324 echo col("'" .. markname) " column of mark markname 1325 < 1326 The first column is 1. Returns 0 if {expr} is invalid or when 1327 the window with ID {winid} is not found. 1328 For an uppercase mark the column may actually be in another 1329 buffer. 1330 For the cursor position, when 'virtualedit' is active, the 1331 column is one higher if the cursor is after the end of the 1332 line. Also, when using a <Cmd> mapping the cursor isn't 1333 moved, this can be used to obtain the column in Insert mode: >vim 1334 imap <F2> <Cmd>echo col(".").."\n"<CR> 1335 < 1336 1337 ]=], 1338 name = 'col', 1339 params = { { 'expr', 'string|any[]' }, { 'winid', 'integer' } }, 1340 returns = 'integer', 1341 signature = 'col({expr} [, {winid}])', 1342 }, 1343 complete = { 1344 args = 2, 1345 base = 2, 1346 desc = [=[ 1347 Set the matches for Insert mode completion. Can only be used 1348 in Insert mode. Typically invoked from a mapping with 1349 CTRL-R = (see |i_CTRL-R|), but may also be called from a 1350 |<Cmd>| mapping. It does not work after CTRL-O or with an 1351 expression mapping. 1352 {startcol} is the byte offset in the line where the completed 1353 text start. The text up to the cursor is the original text 1354 that will be replaced by the matches. Use col('.') for an 1355 empty string. "col('.') - 1" will replace one character by a 1356 match. 1357 {matches} must be a |List|. Each |List| item is one match. 1358 See |complete-items| for the kind of items that are possible. 1359 "longest" in 'completeopt' is ignored. 1360 Note that the after calling this function you need to avoid 1361 inserting anything that would cause completion to stop. 1362 The match can be selected with CTRL-N and CTRL-P as usual with 1363 Insert mode completion. The popup menu will appear if 1364 specified, see |ins-completion-menu|. 1365 Example: >vim 1366 1367 inoremap <F5> <C-R>=ListMonths()<CR> 1368 1369 func ListMonths() 1370 call complete(col('.'), ['January', 'February', 'March', 1371 \ 'April', 'May', 'June', 'July', 'August', 1372 \ 'September', 'October', 'November', 'December']) 1373 return '' 1374 endfunc 1375 1376 <This isn't very useful, but it shows how it works. Note that 1377 an empty string is returned to avoid a zero being inserted. 1378 1379 ]=], 1380 name = 'complete', 1381 params = { { 'startcol', 'integer' }, { 'matches', 'any[]' } }, 1382 returns = false, 1383 signature = 'complete({startcol}, {matches})', 1384 tags = { 'E785' }, 1385 }, 1386 complete_add = { 1387 args = 1, 1388 base = 1, 1389 desc = [=[ 1390 Add {expr} to the list of matches. Only to be used by the 1391 function specified with the 'completefunc' option. 1392 Returns 0 for failure (empty string or out of memory), 1393 1 when the match was added, 2 when the match was already in 1394 the list. 1395 See |complete-functions| for an explanation of {expr}. It is 1396 the same as one item in the list that 'omnifunc' would return. 1397 1398 ]=], 1399 name = 'complete_add', 1400 params = { { 'expr', 'any' } }, 1401 returns = '0|1|2', 1402 signature = 'complete_add({expr})', 1403 }, 1404 complete_check = { 1405 desc = [=[ 1406 Check for a key typed while looking for completion matches. 1407 This is to be used when looking for matches takes some time. 1408 Returns |TRUE| when searching for matches is to be aborted, 1409 zero otherwise. 1410 Only to be used by the function specified with the 1411 'completefunc' option. 1412 ]=], 1413 name = 'complete_check', 1414 params = {}, 1415 returns = '0|1', 1416 signature = 'complete_check()', 1417 }, 1418 complete_info = { 1419 args = { 0, 1 }, 1420 base = 1, 1421 desc = [=[ 1422 Returns a |Dictionary| with information about Insert mode 1423 completion. See |ins-completion|. 1424 The items are: 1425 completed Return a dictionary containing the entries of 1426 the currently selected index item. 1427 items List of all completion candidates. Each item 1428 is a dictionary containing the entries "word", 1429 "abbr", "menu", "kind", "info" and 1430 "user_data". 1431 See |complete-items|. 1432 matches Same as "items", but only returns items that 1433 are matching current query. If both "matches" 1434 and "items" are in "what", the returned list 1435 will still be named "items", but each item 1436 will have an additional "match" field. 1437 mode Current completion mode name string. 1438 See |complete_info_mode| for the values. 1439 preinserted_text 1440 The actual text that is pre-inserted, see 1441 |preinserted()|. 1442 pum_visible |TRUE| if popup menu is visible. 1443 See |pumvisible()|. 1444 selected Selected item index. First index is zero. 1445 Index is -1 if no item is selected (showing 1446 typed text only, or the last completion after 1447 no item is selected when using the <Up> or 1448 <Down> keys) 1449 preview_winid Info floating preview window id. 1450 preview_bufnr Info floating preview buffer id. 1451 1452 *complete_info_mode* 1453 mode values are: 1454 "" Not in completion mode 1455 "keyword" Keyword completion |i_CTRL-X_CTRL-N| 1456 "ctrl_x" Just pressed CTRL-X |i_CTRL-X| 1457 "scroll" Scrolling with |i_CTRL-X_CTRL-E| or 1458 |i_CTRL-X_CTRL-Y| 1459 "whole_line" Whole lines |i_CTRL-X_CTRL-L| 1460 "files" File names |i_CTRL-X_CTRL-F| 1461 "tags" Tags |i_CTRL-X_CTRL-]| 1462 "path_defines" Definition completion |i_CTRL-X_CTRL-D| 1463 "path_patterns" Include completion |i_CTRL-X_CTRL-I| 1464 "dictionary" Dictionary |i_CTRL-X_CTRL-K| 1465 "thesaurus" Thesaurus |i_CTRL-X_CTRL-T| 1466 "cmdline" Vim Command line |i_CTRL-X_CTRL-V| 1467 "function" User defined completion |i_CTRL-X_CTRL-U| 1468 "omni" Omni completion |i_CTRL-X_CTRL-O| 1469 "spell" Spelling suggestions |i_CTRL-X_s| 1470 "eval" |complete()| completion 1471 "register" Words from registers |i_CTRL-X_CTRL-R| 1472 "unknown" Other internal modes 1473 1474 If the optional {what} list argument is supplied, then only 1475 the items listed in {what} are returned. Unsupported items in 1476 {what} are silently ignored. 1477 1478 To get the position and size of the popup menu, see 1479 |pum_getpos()|. It's also available in |v:event| during the 1480 |CompleteChanged| event. 1481 1482 Returns an empty |Dictionary| on error. 1483 1484 Examples: >vim 1485 " Get all items 1486 call complete_info() 1487 " Get only 'mode' 1488 call complete_info(['mode']) 1489 " Get only 'mode' and 'pum_visible' 1490 call complete_info(['mode', 'pum_visible']) 1491 < 1492 1493 ]=], 1494 name = 'complete_info', 1495 params = { { 'what', 'any[]' } }, 1496 returns = 'table', 1497 signature = 'complete_info([{what}])', 1498 }, 1499 confirm = { 1500 args = { 1, 4 }, 1501 base = 1, 1502 desc = [=[ 1503 confirm() offers the user a dialog, from which a choice can be 1504 made. It returns the number of the choice. For the first 1505 choice this is 1. 1506 1507 {msg} is displayed in a dialog with {choices} as the 1508 alternatives. When {choices} is missing or empty, "&OK" is 1509 used (and translated). 1510 {msg} is a String, use '\n' to include a newline. Only on 1511 some systems the string is wrapped when it doesn't fit. 1512 1513 {choices} is a String, with the individual choices separated 1514 by '\n', e.g. >vim 1515 confirm("Save changes?", "&Yes\n&No\n&Cancel") 1516 <The letter after the '&' is the shortcut key for that choice. 1517 Thus you can type 'c' to select "Cancel". The shortcut does 1518 not need to be the first letter: >vim 1519 confirm("file has been modified", "&Save\nSave &All") 1520 <For the console, the first letter of each choice is used as 1521 the default shortcut key. Case is ignored. 1522 1523 The optional {type} String argument gives the type of dialog. 1524 It can be one of these values: "Error", "Question", "Info", 1525 "Warning" or "Generic". Only the first character is relevant. 1526 When {type} is omitted, "Generic" is used. 1527 1528 The optional {type} argument gives the type of dialog. This 1529 is only used for the icon of the Win32 GUI. It can be one of 1530 these values: "Error", "Question", "Info", "Warning" or 1531 "Generic". Only the first character is relevant. 1532 When {type} is omitted, "Generic" is used. 1533 1534 If the user aborts the dialog by pressing <Esc>, CTRL-C, 1535 or another valid interrupt key, confirm() returns 0. 1536 1537 An example: >vim 1538 let choice = confirm("What do you want?", 1539 \ "&Apples\n&Oranges\n&Bananas", 2) 1540 if choice == 0 1541 echo "make up your mind!" 1542 elseif choice == 3 1543 echo "tasteful" 1544 else 1545 echo "I prefer bananas myself." 1546 endif 1547 <In a GUI dialog, buttons are used. The layout of the buttons 1548 depends on the 'v' flag in 'guioptions'. If it is included, 1549 the buttons are always put vertically. Otherwise, confirm() 1550 tries to put the buttons in one horizontal line. If they 1551 don't fit, a vertical layout is used anyway. For some systems 1552 the horizontal layout is always used. 1553 1554 ]=], 1555 name = 'confirm', 1556 params = { 1557 { 'msg', 'string' }, 1558 { 'choices', 'string' }, 1559 { 'default', 'integer' }, 1560 { 'type', 'string' }, 1561 }, 1562 returns = 'integer', 1563 signature = 'confirm({msg} [, {choices} [, {default} [, {type}]]])', 1564 }, 1565 copy = { 1566 args = 1, 1567 base = 1, 1568 desc = [=[ 1569 Make a copy of {expr}. For Numbers and Strings this isn't 1570 different from using {expr} directly. 1571 When {expr} is a |List| a shallow copy is created. This means 1572 that the original |List| can be changed without changing the 1573 copy, and vice versa. But the items are identical, thus 1574 changing an item changes the contents of both |Lists|. 1575 A |Dictionary| is copied in a similar way as a |List|. 1576 Also see |deepcopy()|. 1577 ]=], 1578 generics = { 'T' }, 1579 name = 'copy', 1580 params = { { 'expr', 'T' } }, 1581 returns = 'T', 1582 signature = 'copy({expr})', 1583 }, 1584 cos = { 1585 args = 1, 1586 base = 1, 1587 desc = [=[ 1588 Return the cosine of {expr}, measured in radians, as a |Float|. 1589 {expr} must evaluate to a |Float| or a |Number|. 1590 Returns 0.0 if {expr} is not a |Float| or a |Number|. 1591 Examples: >vim 1592 echo cos(100) 1593 < 0.862319 >vim 1594 echo cos(-4.01) 1595 < -0.646043 1596 1597 ]=], 1598 float_func = 'cos', 1599 name = 'cos', 1600 params = { { 'expr', 'number' } }, 1601 returns = 'number', 1602 signature = 'cos({expr})', 1603 }, 1604 cosh = { 1605 args = 1, 1606 base = 1, 1607 desc = [=[ 1608 Return the hyperbolic cosine of {expr} as a |Float| in the range 1609 [1, inf]. 1610 {expr} must evaluate to a |Float| or a |Number|. 1611 Returns 0.0 if {expr} is not a |Float| or a |Number|. 1612 Examples: >vim 1613 echo cosh(0.5) 1614 < 1.127626 >vim 1615 echo cosh(-0.5) 1616 < -1.127626 1617 1618 ]=], 1619 float_func = 'cosh', 1620 name = 'cosh', 1621 params = { { 'expr', 'number' } }, 1622 returns = 'number', 1623 signature = 'cosh({expr})', 1624 }, 1625 count = { 1626 args = { 2, 4 }, 1627 base = 1, 1628 tags = { 'E706' }, 1629 desc = [=[ 1630 Return the number of times an item with value {expr} appears 1631 in |String|, |List| or |Dictionary| {comp}. 1632 1633 If {start} is given then start with the item with this index. 1634 {start} can only be used with a |List|. 1635 1636 When {ic} is given and it's |TRUE| then case is ignored. 1637 1638 When {comp} is a string then the number of not overlapping 1639 occurrences of {expr} is returned. Zero is returned when 1640 {expr} is an empty string. 1641 1642 ]=], 1643 name = 'count', 1644 params = { 1645 { 'comp', 'string|table|any[]' }, 1646 { 'expr', 'any' }, 1647 { 'ic', 'boolean' }, 1648 { 'start', 'integer' }, 1649 }, 1650 returns = 'integer', 1651 signature = 'count({comp}, {expr} [, {ic} [, {start}]])', 1652 }, 1653 ctxget = { 1654 args = { 0, 1 }, 1655 desc = [=[ 1656 Returns a |Dictionary| representing the |context| at {index} 1657 from the top of the |context-stack| (see |context-dict|). 1658 If {index} is not given, it is assumed to be 0 (i.e.: top). 1659 ]=], 1660 name = 'ctxget', 1661 params = { { 'index', 'integer' } }, 1662 returns = 'table', 1663 signature = 'ctxget([{index}])', 1664 }, 1665 ctxpop = { 1666 desc = [=[ 1667 Pops and restores the |context| at the top of the 1668 |context-stack|. 1669 ]=], 1670 name = 'ctxpop', 1671 params = {}, 1672 signature = 'ctxpop()', 1673 }, 1674 ctxpush = { 1675 args = { 0, 1 }, 1676 desc = [=[ 1677 Pushes the current editor state (|context|) on the 1678 |context-stack|. 1679 If {types} is given and is a |List| of |String|s, it specifies 1680 which |context-types| to include in the pushed context. 1681 Otherwise, all context types are included. 1682 ]=], 1683 name = 'ctxpush', 1684 params = { { 'types', 'string[]' } }, 1685 signature = 'ctxpush([{types}])', 1686 }, 1687 ctxset = { 1688 args = { 1, 2 }, 1689 desc = [=[ 1690 Sets the |context| at {index} from the top of the 1691 |context-stack| to that represented by {context}. 1692 {context} is a Dictionary with context data (|context-dict|). 1693 If {index} is not given, it is assumed to be 0 (i.e.: top). 1694 ]=], 1695 name = 'ctxset', 1696 params = { { 'context', 'table' }, { 'index', 'integer' } }, 1697 returns = 'integer', 1698 signature = 'ctxset({context} [, {index}])', 1699 }, 1700 ctxsize = { 1701 desc = [=[ 1702 Returns the size of the |context-stack|. 1703 ]=], 1704 name = 'ctxsize', 1705 params = {}, 1706 signature = 'ctxsize()', 1707 }, 1708 cursor = { 1709 args = { 1, 3 }, 1710 base = 1, 1711 name = 'cursor', 1712 params = { { 'lnum', 'integer|string' }, { 'col', 'integer' }, { 'off', 'integer' } }, 1713 signature = 'cursor({lnum}, {col} [, {off}])', 1714 }, 1715 cursor__1 = { 1716 args = { 1, 3 }, 1717 base = 1, 1718 desc = [=[ 1719 Positions the cursor at the column (byte count) {col} in the 1720 line {lnum}. The first column is one. 1721 1722 When there is one argument {list} this is used as a |List| 1723 with two, three or four item: 1724 [{lnum}, {col}] 1725 [{lnum}, {col}, {off}] 1726 [{lnum}, {col}, {off}, {curswant}] 1727 This is like the return value of |getpos()| or |getcurpos()|, 1728 but without the first item. 1729 1730 To position the cursor using {col} as the character count, use 1731 |setcursorcharpos()|. 1732 1733 Does not change the jumplist. 1734 {lnum} is used like with |getline()|, except that if {lnum} is 1735 zero, the cursor will stay in the current line. 1736 If {lnum} is greater than the number of lines in the buffer, 1737 the cursor will be positioned at the last line in the buffer. 1738 If {col} is greater than the number of bytes in the line, 1739 the cursor will be positioned at the last character in the 1740 line. 1741 If {col} is zero, the cursor will stay in the current column. 1742 If {curswant} is given it is used to set the preferred column 1743 for vertical movement. Otherwise {col} is used. 1744 1745 When 'virtualedit' is used {off} specifies the offset in 1746 screen columns from the start of the character. E.g., a 1747 position within a <Tab> or after the last character. 1748 Returns 0 when the position could be set, -1 otherwise. 1749 1750 ]=], 1751 name = 'cursor', 1752 params = { { 'list', 'integer[]' } }, 1753 signature = 'cursor({list})', 1754 }, 1755 debugbreak = { 1756 args = { 1, 1 }, 1757 base = 1, 1758 desc = [=[ 1759 Specifically used to interrupt a program being debugged. It 1760 will cause process {pid} to get a SIGTRAP. Behavior for other 1761 processes is undefined. See |terminal-debug|. 1762 (Sends a SIGINT to a process {pid} other than MS-Windows) 1763 1764 Returns |TRUE| if successfully interrupted the program. 1765 Otherwise returns |FALSE|. 1766 1767 ]=], 1768 name = 'debugbreak', 1769 params = { { 'pid', 'integer' } }, 1770 signature = 'debugbreak({pid})', 1771 }, 1772 deepcopy = { 1773 args = { 1, 2 }, 1774 base = 1, 1775 tags = { 'E698' }, 1776 desc = [=[ 1777 Make a copy of {expr}. For Numbers and Strings this isn't 1778 different from using {expr} directly. 1779 When {expr} is a |List| a full copy is created. This means 1780 that the original |List| can be changed without changing the 1781 copy, and vice versa. When an item is a |List|, a copy for it 1782 is made, recursively. Thus changing an item in the copy does 1783 not change the contents of the original |List|. 1784 1785 When {noref} is omitted or zero a contained |List| or 1786 |Dictionary| is only copied once. All references point to 1787 this single copy. With {noref} set to 1 every occurrence of a 1788 |List| or |Dictionary| results in a new copy. This also means 1789 that a cyclic reference causes deepcopy() to fail. 1790 *E724* 1791 Nesting is possible up to 100 levels. When there is an item 1792 that refers back to a higher level making a deep copy with 1793 {noref} set to 1 will fail. 1794 Also see |copy()|. 1795 1796 ]=], 1797 generics = { 'T' }, 1798 name = 'deepcopy', 1799 params = { { 'expr', 'T' }, { 'noref', 'boolean' } }, 1800 returns = 'T', 1801 signature = 'deepcopy({expr} [, {noref}])', 1802 }, 1803 delete = { 1804 args = { 1, 2 }, 1805 base = 1, 1806 desc = [=[ 1807 Without {flags} or with {flags} empty: Deletes the file by the 1808 name {fname}. 1809 1810 This also works when {fname} is a symbolic link. The symbolic 1811 link itself is deleted, not what it points to. 1812 1813 When {flags} is "d": Deletes the directory by the name 1814 {fname}. This fails when directory {fname} is not empty. 1815 1816 When {flags} is "rf": Deletes the directory by the name 1817 {fname} and everything in it, recursively. BE CAREFUL! 1818 Note: on MS-Windows it is not possible to delete a directory 1819 that is being used. 1820 1821 The result is a Number, which is 0/false if the delete 1822 operation was successful and -1/true when the deletion failed 1823 or partly failed. 1824 1825 ]=], 1826 name = 'delete', 1827 params = { { 'fname', 'string' }, { 'flags', 'string' } }, 1828 returns = 'integer', 1829 signature = 'delete({fname} [, {flags}])', 1830 }, 1831 deletebufline = { 1832 args = { 2, 3 }, 1833 base = 1, 1834 desc = [=[ 1835 Delete lines {first} to {last} (inclusive) from buffer {buf}. 1836 If {last} is omitted then delete line {first} only. 1837 On success 0 is returned, on failure 1 is returned. 1838 1839 This function works only for loaded buffers. First call 1840 |bufload()| if needed. 1841 1842 For the use of {buf}, see |bufname()| above. 1843 1844 {first} and {last} are used like with |getline()|. Note that 1845 when using |line()| this refers to the current buffer. Use "$" 1846 to refer to the last line in buffer {buf}. 1847 1848 ]=], 1849 name = 'deletebufline', 1850 params = { 1851 { 'buf', 'integer|string' }, 1852 { 'first', 'integer|string' }, 1853 { 'last', 'integer|string' }, 1854 }, 1855 signature = 'deletebufline({buf}, {first} [, {last}])', 1856 }, 1857 dictwatcheradd = { 1858 args = 3, 1859 desc = [=[ 1860 Adds a watcher to a dictionary. A dictionary watcher is 1861 identified by three components: 1862 1863 - A dictionary({dict}); 1864 - A key pattern({pattern}). 1865 - A function({callback}). 1866 1867 After this is called, every change on {dict} and on keys 1868 matching {pattern} will result in {callback} being invoked. 1869 1870 For example, to watch all global variables: >vim 1871 silent! call dictwatcherdel(g:, '*', 'OnDictChanged') 1872 function! OnDictChanged(d,k,z) 1873 echomsg string(a:k) string(a:z) 1874 endfunction 1875 call dictwatcheradd(g:, '*', 'OnDictChanged') 1876 < 1877 For now {pattern} only accepts very simple patterns that can 1878 contain a "*" at the end of the string, in which case it will 1879 match every key that begins with the substring before the "*". 1880 That means if "*" is not the last character of {pattern}, only 1881 keys that are exactly equal as {pattern} will be matched. 1882 1883 The {callback} receives three arguments: 1884 1885 - The dictionary being watched. 1886 - The key which changed. 1887 - A dictionary containing the new and old values for the key. 1888 1889 The type of change can be determined by examining the keys 1890 present on the third argument: 1891 1892 - If contains both `old` and `new`, the key was updated. 1893 - If it contains only `new`, the key was added. 1894 - If it contains only `old`, the key was deleted. 1895 1896 This function can be used by plugins to implement options with 1897 validation and parsing logic. 1898 ]=], 1899 name = 'dictwatcheradd', 1900 params = { { 'dict', 'table' }, { 'pattern', 'string' }, { 'callback', 'function' } }, 1901 signature = 'dictwatcheradd({dict}, {pattern}, {callback})', 1902 }, 1903 dictwatcherdel = { 1904 args = 3, 1905 desc = [=[ 1906 Removes a watcher added with |dictwatcheradd()|. All three 1907 arguments must match the ones passed to |dictwatcheradd()| in 1908 order for the watcher to be successfully deleted. 1909 ]=], 1910 name = 'dictwatcherdel', 1911 params = { { 'dict', 'any' }, { 'pattern', 'string' }, { 'callback', 'function' } }, 1912 signature = 'dictwatcherdel({dict}, {pattern}, {callback})', 1913 }, 1914 did_filetype = { 1915 desc = [=[ 1916 Returns |TRUE| when autocommands are being executed and the 1917 FileType event has been triggered at least once. Can be used 1918 to avoid triggering the FileType event again in the scripts 1919 that detect the file type. |FileType| 1920 Returns |FALSE| when `:setf FALLBACK` was used. 1921 When editing another file, the counter is reset, thus this 1922 really checks if the FileType event has been triggered for the 1923 current buffer. This allows an autocommand that starts 1924 editing another buffer to set 'filetype' and load a syntax 1925 file. 1926 ]=], 1927 fast = true, 1928 name = 'did_filetype', 1929 params = {}, 1930 returns = 'integer', 1931 signature = 'did_filetype()', 1932 }, 1933 diff_filler = { 1934 args = 1, 1935 base = 1, 1936 desc = [=[ 1937 Returns the number of filler lines above line {lnum}. 1938 These are the lines that were inserted at this point in 1939 another diff'ed window. These filler lines are shown in the 1940 display but don't exist in the buffer. 1941 {lnum} is used like with |getline()|. Thus "." is the current 1942 line, "'m" mark m, etc. 1943 Returns 0 if the current window is not in diff mode. 1944 1945 ]=], 1946 name = 'diff_filler', 1947 params = { { 'lnum', 'integer|string' } }, 1948 returns = 'integer', 1949 signature = 'diff_filler({lnum})', 1950 }, 1951 diff_hlID = { 1952 args = 2, 1953 base = 1, 1954 desc = [=[ 1955 Returns the highlight ID for diff mode at line {lnum} column 1956 {col} (byte index). When the current line does not have a 1957 diff change zero is returned. 1958 {lnum} is used like with |getline()|. Thus "." is the current 1959 line, "'m" mark m, etc. 1960 {col} is 1 for the leftmost column, {lnum} is 1 for the first 1961 line. 1962 The highlight ID can be used with |synIDattr()| to obtain 1963 syntax information about the highlighting. 1964 1965 ]=], 1966 name = 'diff_hlID', 1967 params = { { 'lnum', 'integer|string' }, { 'col', 'integer' } }, 1968 signature = 'diff_hlID({lnum}, {col})', 1969 }, 1970 digraph_get = { 1971 args = 1, 1972 base = 1, 1973 tags = { 'E1214' }, 1974 desc = [=[ 1975 Return the digraph of {chars}. This should be a string with 1976 exactly two characters. If {chars} are not just two 1977 characters, or the digraph of {chars} does not exist, an error 1978 is given and an empty string is returned. 1979 1980 Also see |digraph_getlist()|. 1981 1982 Examples: >vim 1983 " Get a built-in digraph 1984 echo digraph_get('00') " Returns '∞' 1985 1986 " Get a user-defined digraph 1987 call digraph_set('aa', 'あ') 1988 echo digraph_get('aa') " Returns 'あ' 1989 < 1990 ]=], 1991 name = 'digraph_get', 1992 params = { { 'chars', 'string' } }, 1993 returns = 'string', 1994 signature = 'digraph_get({chars})', 1995 }, 1996 digraph_getlist = { 1997 args = { 0, 1 }, 1998 base = 1, 1999 desc = [=[ 2000 Return a list of digraphs. If the {listall} argument is given 2001 and it is TRUE, return all digraphs, including the default 2002 digraphs. Otherwise, return only user-defined digraphs. 2003 2004 Also see |digraph_get()|. 2005 2006 Examples: >vim 2007 " Get user-defined digraphs 2008 echo digraph_getlist() 2009 2010 " Get all the digraphs, including default digraphs 2011 echo digraph_getlist(1) 2012 < 2013 ]=], 2014 name = 'digraph_getlist', 2015 params = { { 'listall', 'boolean' } }, 2016 returns = 'string[][]', 2017 signature = 'digraph_getlist([{listall}])', 2018 }, 2019 digraph_set = { 2020 args = 2, 2021 base = 1, 2022 desc = [=[ 2023 Add digraph {chars} to the list. {chars} must be a string 2024 with two characters. {digraph} is a string with one UTF-8 2025 encoded character. *E1215* 2026 Be careful, composing characters are NOT ignored. This 2027 function is similar to |:digraphs| command, but useful to add 2028 digraphs start with a white space. 2029 2030 The function result is v:true if |digraph| is registered. If 2031 this fails an error message is given and v:false is returned. 2032 2033 If you want to define multiple digraphs at once, you can use 2034 |digraph_setlist()|. 2035 2036 Example: >vim 2037 call digraph_set(' ', 'あ') 2038 < 2039 ]=], 2040 name = 'digraph_set', 2041 params = { { 'chars', 'string' }, { 'digraph', 'string' } }, 2042 signature = 'digraph_set({chars}, {digraph})', 2043 }, 2044 digraph_setlist = { 2045 args = 1, 2046 base = 1, 2047 desc = [=[ 2048 Similar to |digraph_set()| but this function can add multiple 2049 digraphs at once. {digraphlist} is a list composed of lists, 2050 where each list contains two strings with {chars} and 2051 {digraph} as in |digraph_set()|. *E1216* 2052 Example: >vim 2053 call digraph_setlist([['aa', 'あ'], ['ii', 'い']]) 2054 < 2055 It is similar to the following: >vim 2056 for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']] 2057 call digraph_set(chars, digraph) 2058 endfor 2059 <Except that the function returns after the first error, 2060 following digraphs will not be added. 2061 ]=], 2062 name = 'digraph_setlist', 2063 params = { { 'digraphlist', 'table<integer,string[]>' } }, 2064 signature = 'digraph_setlist({digraphlist})', 2065 }, 2066 empty = { 2067 args = 1, 2068 base = 1, 2069 desc = [=[ 2070 Return the Number 1 if {expr} is empty, zero otherwise. 2071 - A |List| or |Dictionary| is empty when it does not have any 2072 items. 2073 - A |String| is empty when its length is zero. 2074 - A |Number| and |Float| are empty when their value is zero. 2075 - |v:false| and |v:null| are empty, |v:true| is not. 2076 - A |Blob| is empty when its length is zero. 2077 2078 ]=], 2079 name = 'empty', 2080 params = { { 'expr', 'any' } }, 2081 returns = 'integer', 2082 signature = 'empty({expr})', 2083 }, 2084 environ = { 2085 desc = [=[ 2086 Return all of environment variables as dictionary. You can 2087 check if an environment variable exists like this: >vim 2088 echo has_key(environ(), 'HOME') 2089 <Note that the variable name may be CamelCase; to ignore case 2090 use this: >vim 2091 echo index(keys(environ()), 'HOME', 0, 1) != -1 2092 < 2093 ]=], 2094 fast = true, 2095 name = 'environ', 2096 params = {}, 2097 signature = 'environ()', 2098 }, 2099 escape = { 2100 args = 2, 2101 base = 1, 2102 desc = [=[ 2103 Escape the characters in {chars} that occur in {string} with a 2104 backslash. Example: >vim 2105 echo escape('c:\program files\vim', ' \') 2106 <results in: > 2107 c:\\program\ files\\vim 2108 <Also see |shellescape()| and |fnameescape()|. 2109 2110 ]=], 2111 fast = true, 2112 name = 'escape', 2113 params = { { 'string', 'string' }, { 'chars', 'string' } }, 2114 returns = 'string', 2115 signature = 'escape({string}, {chars})', 2116 }, 2117 eval = { 2118 args = 1, 2119 base = 1, 2120 desc = [=[ 2121 Evaluate {string} and return the result. Especially useful to 2122 turn the result of |string()| back into the original value. 2123 This works for Numbers, Floats, Strings, Blobs and composites 2124 of them. Also works for |Funcref|s that refer to existing 2125 functions. 2126 2127 ]=], 2128 name = 'eval', 2129 params = { { 'string', 'string' } }, 2130 signature = 'eval({string})', 2131 }, 2132 eventhandler = { 2133 desc = [=[ 2134 Returns 1 when inside an event handler. That is that Vim got 2135 interrupted while waiting for the user to type a character, 2136 e.g., when dropping a file on Vim. This means interactive 2137 commands cannot be used. Otherwise zero is returned. 2138 ]=], 2139 name = 'eventhandler', 2140 params = {}, 2141 signature = 'eventhandler()', 2142 }, 2143 executable = { 2144 args = 1, 2145 base = 1, 2146 desc = [=[ 2147 This function checks if an executable with the name {expr} 2148 exists. {expr} must be the name of the program without any 2149 arguments. 2150 2151 executable() uses the value of $PATH and/or the normal 2152 searchpath for programs. 2153 *PATHEXT* 2154 On MS-Windows the ".exe", ".bat", etc. can optionally be 2155 included. Then the extensions in $PATHEXT are tried. Thus if 2156 "foo.exe" does not exist, "foo.exe.bat" can be found. If 2157 $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot 2158 by itself can be used in $PATHEXT to try using the name 2159 without an extension. When 'shell' looks like a Unix shell, 2160 then the name is also tried without adding an extension. 2161 On MS-Windows it only checks if the file exists and is not a 2162 directory, not if it's really executable. 2163 2164 On MS-Windows an executable in the same directory as the Vim 2165 executable is always found (it's added to $PATH at |startup|). 2166 *$NoDefaultCurrentDirectoryInExePath* 2167 On MS-Windows when using cmd.exe as 'shell' an executable in 2168 Vim's current working directory is also normally found, which 2169 can be disabled by setting the 2170 `$NoDefaultCurrentDirectoryInExePath` environment variable. 2171 This variable is always set by Vim when executing external 2172 commands (e.g., via |:!|, |:make|, or |system()|) for security 2173 reasons. 2174 2175 The result is a Number: 2176 1 exists 2177 0 does not exist 2178 |exepath()| can be used to get the full path of an executable. 2179 2180 ]=], 2181 fast = true, 2182 name = 'executable', 2183 params = { { 'expr', 'string' } }, 2184 returns = '0|1', 2185 signature = 'executable({expr})', 2186 }, 2187 execute = { 2188 args = { 1, 2 }, 2189 base = 1, 2190 desc = [=[ 2191 Execute {command} and capture its output. 2192 If {command} is a |String|, returns {command} output. 2193 If {command} is a |List|, returns concatenated outputs. 2194 Line continuations in {command} are not recognized. 2195 Examples: >vim 2196 echo execute('echon "foo"') 2197 < foo >vim 2198 echo execute(['echon "foo"', 'echon "bar"']) 2199 < foobar 2200 2201 The optional {silent} argument can have these values: 2202 "" no `:silent` used 2203 "silent" `:silent` used 2204 "silent!" `:silent!` used 2205 The default is "silent". Note that with "silent!", unlike 2206 `:redir`, error messages are dropped. 2207 2208 To get a list of lines use `split()` on the result: >vim 2209 execute('args')->split("\n") 2210 2211 <This function is not available in the |sandbox|. 2212 Note: If nested, an outer execute() will not observe output of 2213 the inner calls. 2214 Note: Text attributes (highlights) are not captured. 2215 To execute a command in another window than the current one 2216 use `win_execute()`. 2217 2218 ]=], 2219 name = 'execute', 2220 params = { 2221 { 'command', 'string|string[]' }, 2222 { 'silent', "''|'silent'|'silent!'" }, 2223 }, 2224 returns = 'string', 2225 signature = 'execute({command} [, {silent}])', 2226 }, 2227 exepath = { 2228 args = 1, 2229 base = 1, 2230 desc = [=[ 2231 Returns the full path of {expr} if it is an executable and 2232 given as a (partial or full) path or is found in $PATH. 2233 Returns empty string otherwise. 2234 If {expr} starts with "./" the |current-directory| is used. 2235 2236 ]=], 2237 fast = true, 2238 name = 'exepath', 2239 params = { { 'expr', 'string' } }, 2240 signature = 'exepath({expr})', 2241 returns = 'string', 2242 }, 2243 exists = { 2244 args = 1, 2245 base = 1, 2246 desc = [=[ 2247 The result is a Number, which is |TRUE| if {expr} is 2248 defined, zero otherwise. 2249 2250 For checking for a supported feature use |has()|. 2251 For checking if a file exists use |filereadable()|. 2252 2253 The {expr} argument is a string, which contains one of these: 2254 varname internal variable (see 2255 dict.key |internal-variables|). Also works 2256 list[i] for |curly-braces-names|, |Dictionary| 2257 entries, |List| items, etc. 2258 Beware that evaluating an index may 2259 cause an error message for an invalid 2260 expression. E.g.: >vim 2261 let l = [1, 2, 3] 2262 echo exists("l[5]") 2263 < 0 >vim 2264 echo exists("l[xx]") 2265 < E121: Undefined variable: xx 2266 0 2267 &option-name Vim option (only checks if it exists, 2268 not if it really works) 2269 +option-name Vim option that works. 2270 $ENVNAME environment variable (could also be 2271 done by comparing with an empty 2272 string) 2273 `*funcname` built-in function (see |functions|) 2274 or user defined function (see 2275 |user-function|). Also works for a 2276 variable that is a Funcref. 2277 :cmdname Ex command: built-in command, user 2278 command or command modifier |:command|. 2279 Returns: 2280 1 for match with start of a command 2281 2 full match with a command 2282 3 matches several user commands 2283 To check for a supported command 2284 always check the return value to be 2. 2285 :2match The |:2match| command. 2286 :3match The |:3match| command (but you 2287 probably should not use it, it is 2288 reserved for internal usage) 2289 #event autocommand defined for this event 2290 #event#pattern autocommand defined for this event and 2291 pattern (the pattern is taken 2292 literally and compared to the 2293 autocommand patterns character by 2294 character) 2295 #group autocommand group exists 2296 #group#event autocommand defined for this group and 2297 event. 2298 #group#event#pattern 2299 autocommand defined for this group, 2300 event and pattern. 2301 ##event autocommand for this event is 2302 supported. 2303 2304 Examples: >vim 2305 echo exists("&mouse") 2306 echo exists("$HOSTNAME") 2307 echo exists("*strftime") 2308 echo exists("*s:MyFunc") 2309 echo exists("*MyFunc") 2310 echo exists("*v:lua.Func") 2311 echo exists("bufcount") 2312 echo exists(":Make") 2313 echo exists("#CursorHold") 2314 echo exists("#BufReadPre#*.gz") 2315 echo exists("#filetypeindent") 2316 echo exists("#filetypeindent#FileType") 2317 echo exists("#filetypeindent#FileType#*") 2318 echo exists("##ColorScheme") 2319 <There must be no space between the symbol (&/$/*/#) and the 2320 name. 2321 There must be no extra characters after the name, although in 2322 a few cases this is ignored. That may become stricter in the 2323 future, thus don't count on it! 2324 Working example: >vim 2325 echo exists(":make") 2326 <NOT working example: >vim 2327 echo exists(":make install") 2328 2329 <Note that the argument must be a string, not the name of the 2330 variable itself. For example: >vim 2331 echo exists(bufcount) 2332 <This doesn't check for existence of the "bufcount" variable, 2333 but gets the value of "bufcount", and checks if that exists. 2334 2335 ]=], 2336 name = 'exists', 2337 params = { { 'expr', 'string' } }, 2338 returns = '0|1', 2339 signature = 'exists({expr})', 2340 }, 2341 exp = { 2342 args = 1, 2343 base = 1, 2344 desc = [=[ 2345 Return the exponential of {expr} as a |Float| in the range 2346 [0, inf]. 2347 {expr} must evaluate to a |Float| or a |Number|. 2348 Returns 0.0 if {expr} is not a |Float| or a |Number|. 2349 Examples: >vim 2350 echo exp(2) 2351 < 7.389056 >vim 2352 echo exp(-1) 2353 < 0.367879 2354 2355 ]=], 2356 float_func = 'exp', 2357 name = 'exp', 2358 params = { { 'expr', 'number' } }, 2359 signature = 'exp({expr})', 2360 }, 2361 expand = { 2362 args = { 1, 3 }, 2363 base = 1, 2364 desc = [=[ 2365 Expand wildcards and the following special keywords in 2366 {string}. 'wildignorecase' applies. 2367 2368 If {list} is given and it is |TRUE|, a List will be returned. 2369 Otherwise the result is a String and when there are several 2370 matches, they are separated by <NL> characters. 2371 2372 If the expansion fails, the result is an empty string. A name 2373 for a non-existing file is not included, unless {string} does 2374 not start with '%', '#' or '<', see below. 2375 2376 When {string} starts with '%', '#' or '<', the expansion is 2377 done like for the |cmdline-special| variables with their 2378 associated modifiers. Here is a short overview: 2379 2380 % Current file name 2381 # Alternate file name 2382 #n Alternate file name n 2383 <cfile> File name under the cursor 2384 <afile> Autocmd file name 2385 <abuf> Autocmd buffer number (as a String!) 2386 <amatch> Autocmd matched name 2387 <cexpr> C expression under the cursor 2388 <sfile> Deprecated, use <script> or <stack> 2389 <slnum> Sourced script line number or function 2390 line number 2391 <sflnum> Script file line number, also when in 2392 a function 2393 <SID> "<SNR>123_" where "123" is the 2394 current script ID |<SID>| 2395 <script> Sourced script file, or script file 2396 where the current function was defined. 2397 For Lua see |lua-script-location|. 2398 <stack> Call stack 2399 <cword> Word under the cursor 2400 <cWORD> WORD under the cursor 2401 <client> The {clientid} of the last received 2402 message 2403 Modifiers: 2404 :p Expand to full path 2405 :h Head (last path component removed) 2406 :t Tail (last path component only) 2407 :r Root (one extension removed) 2408 :e Extension only 2409 2410 More modifiers are supported, for the full list see 2411 |filename-modifiers|. 2412 2413 Example: >vim 2414 let &tags = expand("%:p:h") .. "/tags" 2415 <Note that when expanding a string that starts with '%', '#' or 2416 '<', any following text is ignored. This does NOT work: >vim 2417 let doesntwork = expand("%:h.bak") 2418 <Use this: >vim 2419 let doeswork = expand("%:h") .. ".bak" 2420 <Also note that expanding "<cfile>" and others only returns the 2421 referenced file name without further expansion. If "<cfile>" 2422 is "~/.cshrc", you need to do another expand() to have the 2423 "~/" expanded into the path of the home directory: >vim 2424 echo expand(expand("<cfile>")) 2425 < 2426 There cannot be white space between the variables and the 2427 following modifier. The |fnamemodify()| function can be used 2428 to modify normal file names. 2429 2430 When using '%' or '#', and the current or alternate file name 2431 is not defined, an empty string is used. Using "%:p" in a 2432 buffer with no name, results in the current directory, with a 2433 '/' added. 2434 When 'verbose' is set then expanding '%', '#' and <> items 2435 will result in an error message if the argument cannot be 2436 expanded. 2437 2438 When {string} does not start with '%', '#' or '<', it is 2439 expanded like a file name is expanded on the command line. 2440 'suffixes' and 'wildignore' are used, unless the optional 2441 {nosuf} argument is given and it is |TRUE|. 2442 Names for non-existing files are included. The "**" item can 2443 be used to search in a directory tree. For example, to find 2444 all "README" files in the current directory and below: >vim 2445 echo expand("**/README") 2446 < 2447 expand() can also be used to expand variables and environment 2448 variables that are only known in a shell. But this can be 2449 slow, because a shell may be used to do the expansion. See 2450 |expr-env-expand|. 2451 The expanded variable is still handled like a list of file 2452 names. When an environment variable cannot be expanded, it is 2453 left unchanged. Thus ":echo expand('$FOOBAR')" results in 2454 "$FOOBAR". 2455 2456 See |glob()| for finding existing files. See |system()| for 2457 getting the raw output of an external command. 2458 2459 ]=], 2460 name = 'expand', 2461 params = { { 'string', 'string' }, { 'nosuf', 'boolean' }, { 'list', 'nil|false' } }, 2462 signature = 'expand({string} [, {nosuf} [, {list}]])', 2463 returns = 'string', 2464 }, 2465 expand__1 = { 2466 args = { 3 }, 2467 base = 1, 2468 name = 'expand', 2469 params = { 2470 { 'string', 'string' }, 2471 { 'nosuf', 'boolean' }, 2472 { 'list', 'true|number|string|table' }, 2473 }, 2474 returns = 'string|string[]', 2475 }, 2476 expandcmd = { 2477 args = { 1, 2 }, 2478 base = 1, 2479 desc = [=[ 2480 Expand special items in String {string} like what is done for 2481 an Ex command such as `:edit`. This expands special keywords, 2482 like with |expand()|, and environment variables, anywhere in 2483 {string}. "~user" and "~/path" are only expanded at the 2484 start. 2485 2486 The following items are supported in the {options} Dict 2487 argument: 2488 errmsg If set to TRUE, error messages are displayed 2489 if an error is encountered during expansion. 2490 By default, error messages are not displayed. 2491 2492 Returns the expanded string. If an error is encountered 2493 during expansion, the unmodified {string} is returned. 2494 2495 Example: >vim 2496 echo expandcmd('make %<.o') 2497 < > 2498 make /path/runtime/doc/builtin.o 2499 < >vim 2500 echo expandcmd('make %<.o', {'errmsg': v:true}) 2501 < 2502 ]=], 2503 name = 'expandcmd', 2504 params = { { 'string', 'string' }, { 'options', 'table' } }, 2505 signature = 'expandcmd({string} [, {options}])', 2506 }, 2507 extend = { 2508 args = { 2, 3 }, 2509 base = 1, 2510 desc = [=[ 2511 {expr1} and {expr2} must be both |Lists| or both 2512 |Dictionaries|. 2513 2514 If they are |Lists|: Append {expr2} to {expr1}. 2515 If {expr3} is given insert the items of {expr2} before the 2516 item with index {expr3} in {expr1}. When {expr3} is zero 2517 insert before the first item. When {expr3} is equal to 2518 len({expr1}) then {expr2} is appended. 2519 Examples: >vim 2520 echo sort(extend(mylist, [7, 5])) 2521 call extend(mylist, [2, 3], 1) 2522 <When {expr1} is the same List as {expr2} then the number of 2523 items copied is equal to the original length of the List. 2524 E.g., when {expr3} is 1 you get N new copies of the first item 2525 (where N is the original length of the List). 2526 Use |add()| to concatenate one item to a list. To concatenate 2527 two lists into a new list use the + operator: >vim 2528 let newlist = [1, 2, 3] + [4, 5] 2529 < 2530 If they are |Dictionaries|: 2531 Add all entries from {expr2} to {expr1}. 2532 If a key exists in both {expr1} and {expr2} then {expr3} is 2533 used to decide what to do: 2534 {expr3} = "keep": keep the value of {expr1} 2535 {expr3} = "force": use the value of {expr2} 2536 {expr3} = "error": give an error message *E737* 2537 When {expr3} is omitted then "force" is assumed. 2538 2539 {expr1} is changed when {expr2} is not empty. If necessary 2540 make a copy of {expr1} first or use |extendnew()| to return a 2541 new List/Dictionary. 2542 {expr2} remains unchanged. 2543 When {expr1} is locked and {expr2} is not empty the operation 2544 fails. 2545 Returns {expr1}. Returns 0 on error. 2546 2547 ]=], 2548 name = 'extend', 2549 params = { { 'expr1', 'table' }, { 'expr2', 'table' }, { 'expr3', 'table' } }, 2550 signature = 'extend({expr1}, {expr2} [, {expr3}])', 2551 }, 2552 extendnew = { 2553 args = { 2, 3 }, 2554 base = 1, 2555 desc = [=[ 2556 Like |extend()| but instead of adding items to {expr1} a new 2557 List or Dictionary is created and returned. {expr1} remains 2558 unchanged. 2559 ]=], 2560 name = 'extendnew', 2561 params = { { 'expr1', 'table' }, { 'expr2', 'table' }, { 'expr3', 'table' } }, 2562 signature = 'extendnew({expr1}, {expr2} [, {expr3}])', 2563 }, 2564 feedkeys = { 2565 args = { 1, 2 }, 2566 base = 1, 2567 desc = [=[ 2568 Characters in {string} are queued for processing as if they 2569 come from a mapping or were typed by the user. 2570 2571 By default the string is added to the end of the typeahead 2572 buffer, thus if a mapping is still being executed the 2573 characters come after them. Use the 'i' flag to insert before 2574 other characters, they will be executed next, before any 2575 characters from a mapping. 2576 2577 The function does not wait for processing of keys contained in 2578 {string}. 2579 2580 To include special keys into {string}, use double-quotes 2581 and "\..." notation |expr-quote|. For example, 2582 feedkeys("\<CR>") simulates pressing of the <Enter> key. But 2583 feedkeys('\<CR>') pushes 5 characters. 2584 The |<Ignore>| keycode may be used to exit the 2585 wait-for-character without doing anything. 2586 2587 {mode} is a String, which can contain these character flags: 2588 'm' Remap keys. This is default. If {mode} is absent, 2589 keys are remapped. 2590 'n' Do not remap keys. 2591 't' Handle keys as if typed; otherwise they are handled as 2592 if coming from a mapping. This matters for undo, 2593 opening folds, etc. 2594 'L' Lowlevel input. Other flags are not used. 2595 'i' Insert the string instead of appending (see above). 2596 'x' Execute commands until typeahead is empty. This is 2597 similar to using ":normal!". You can call feedkeys() 2598 several times without 'x' and then one time with 'x' 2599 (possibly with an empty {string}) to execute all the 2600 typeahead. Note that when Vim ends in Insert mode it 2601 will behave as if <Esc> is typed, to avoid getting 2602 stuck, waiting for a character to be typed before the 2603 script continues. 2604 Note that if you manage to call feedkeys() while 2605 executing commands, thus calling it recursively, then 2606 all typeahead will be consumed by the last call. 2607 '!' When used with 'x' will not end Insert mode. Can be 2608 used in a test when a timer is set to exit Insert mode 2609 a little later. Useful for testing CursorHoldI. 2610 2611 Return value is always 0. 2612 2613 ]=], 2614 name = 'feedkeys', 2615 params = { { 'string', 'string' }, { 'mode', 'string' } }, 2616 signature = 'feedkeys({string} [, {mode}])', 2617 }, 2618 file_readable = { 2619 args = 1, 2620 base = 1, 2621 deprecated = true, 2622 desc = [=[ 2623 Obsolete name for |filereadable()|. 2624 ]=], 2625 func = 'f_filereadable', 2626 name = 'file_readable', 2627 params = { { 'file', 'string' } }, 2628 signature = 'file_readable({file})', 2629 }, 2630 filecopy = { 2631 args = 2, 2632 base = 1, 2633 desc = [[ 2634 Copy the file pointed to by the name {from} to {to}. The 2635 result is a Number, which is |TRUE| if the file was copied 2636 successfully, and |FALSE| when it failed. 2637 If a file with name {to} already exists, it will fail. 2638 Note that it does not handle directories (yet). 2639 2640 This function is not available in the |sandbox|. 2641 ]], 2642 name = 'filecopy', 2643 params = { { 'from', 'string' }, { 'to', 'string' } }, 2644 returns = '0|1', 2645 signature = 'filecopy({from}, {to})', 2646 }, 2647 filereadable = { 2648 args = 1, 2649 base = 1, 2650 desc = [=[ 2651 The result is a Number, which is |TRUE| when a file with the 2652 name {file} exists, and can be read. If {file} doesn't exist, 2653 or is a directory, the result is |FALSE|. {file} is any 2654 expression, which is used as a String. 2655 If you don't care about the file being readable you can use 2656 |glob()|. 2657 {file} is used as-is, you may want to expand wildcards first: >vim 2658 echo filereadable('~/.vimrc') 2659 < > 2660 0 2661 < >vim 2662 echo filereadable(expand('~/.vimrc')) 2663 < > 2664 1 2665 < 2666 2667 ]=], 2668 fast = true, 2669 name = 'filereadable', 2670 params = { { 'file', 'string' } }, 2671 returns = '0|1', 2672 signature = 'filereadable({file})', 2673 }, 2674 filewritable = { 2675 args = 1, 2676 base = 1, 2677 desc = [=[ 2678 The result is a Number, which is 1 when a file with the 2679 name {file} exists, and can be written. If {file} doesn't 2680 exist, or is not writable, the result is 0. If {file} is a 2681 directory, and we can write to it, the result is 2. 2682 2683 ]=], 2684 fast = true, 2685 name = 'filewritable', 2686 params = { { 'file', 'string' } }, 2687 returns = '0|1', 2688 signature = 'filewritable({file})', 2689 }, 2690 filter = { 2691 args = 2, 2692 base = 1, 2693 desc = [=[ 2694 {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. 2695 For each item in {expr1} evaluate {expr2} and when the result 2696 is zero or false remove the item from the |List| or 2697 |Dictionary|. Similarly for each byte in a |Blob| and each 2698 character in a |String|. 2699 2700 {expr2} must be a |string| or |Funcref|. 2701 2702 If {expr2} is a |string|, inside {expr2} |v:val| has the value 2703 of the current item. For a |Dictionary| |v:key| has the key 2704 of the current item and for a |List| |v:key| has the index of 2705 the current item. For a |Blob| |v:key| has the index of the 2706 current byte. For a |String| |v:key| has the index of the 2707 current character. 2708 Examples: >vim 2709 call filter(mylist, 'v:val !~ "OLD"') 2710 <Removes the items where "OLD" appears. >vim 2711 call filter(mydict, 'v:key >= 8') 2712 <Removes the items with a key below 8. >vim 2713 call filter(var, 0) 2714 <Removes all the items, thus clears the |List| or |Dictionary|. 2715 2716 Note that {expr2} is the result of expression and is then 2717 used as an expression again. Often it is good to use a 2718 |literal-string| to avoid having to double backslashes. 2719 2720 If {expr2} is a |Funcref| it must take two arguments: 2721 1. the key or the index of the current item. 2722 2. the value of the current item. 2723 The function must return |TRUE| if the item should be kept. 2724 Example that keeps the odd items of a list: >vim 2725 func Odd(idx, val) 2726 return a:idx % 2 == 1 2727 endfunc 2728 call filter(mylist, function('Odd')) 2729 <It is shorter when using a |lambda|: >vim 2730 call filter(myList, {idx, val -> idx * val <= 42}) 2731 <If you do not use "val" you can leave it out: >vim 2732 call filter(myList, {idx -> idx % 2 == 1}) 2733 < 2734 For a |List| and a |Dictionary| the operation is done 2735 in-place. If you want it to remain unmodified make a copy 2736 first: >vim 2737 let l = filter(copy(mylist), 'v:val =~ "KEEP"') 2738 2739 <Returns {expr1}, the |List| or |Dictionary| that was filtered, 2740 or a new |Blob| or |String|. 2741 When an error is encountered while evaluating {expr2} no 2742 further items in {expr1} are processed. 2743 When {expr2} is a Funcref errors inside a function are 2744 ignored, unless it was defined with the "abort" flag. 2745 2746 ]=], 2747 name = 'filter', 2748 params = { { 'expr1', 'string|table' }, { 'expr2', 'string|function' } }, 2749 signature = 'filter({expr1}, {expr2})', 2750 }, 2751 finddir = { 2752 args = { 1, 3 }, 2753 base = 1, 2754 desc = [=[ 2755 Find directory {name} in {path}. Supports both downwards and 2756 upwards recursive directory searches. See |file-searching| 2757 for the syntax of {path}. 2758 2759 Returns the path of the first found match. When the found 2760 directory is below the current directory a relative path is 2761 returned. Otherwise a full path is returned. 2762 If {path} is omitted or empty then 'path' is used. 2763 2764 If the optional {count} is given, find {count}'s occurrence of 2765 {name} in {path} instead of the first one. 2766 When {count} is negative return all the matches in a |List|. 2767 2768 Returns an empty string if the directory is not found. 2769 2770 This is quite similar to the ex-command `:find`. 2771 2772 ]=], 2773 name = 'finddir', 2774 params = { { 'name', 'string' }, { 'path', 'string' }, { 'count', 'integer' } }, 2775 returns = 'string|string[]', 2776 signature = 'finddir({name} [, {path} [, {count}]])', 2777 }, 2778 findfile = { 2779 args = { 1, 3 }, 2780 base = 1, 2781 desc = [=[ 2782 Just like |finddir()|, but find a file instead of a directory. 2783 Uses 'suffixesadd'. 2784 Example: >vim 2785 echo findfile("tags.vim", ".;") 2786 <Searches from the directory of the current file upwards until 2787 it finds the file "tags.vim". 2788 2789 ]=], 2790 name = 'findfile', 2791 params = { { 'name', 'string' }, { 'path', 'string' }, { 'count', 'integer' } }, 2792 returns = 'string|string[]', 2793 signature = 'findfile({name} [, {path} [, {count}]])', 2794 }, 2795 flatten = { 2796 args = { 1, 2 }, 2797 base = 1, 2798 desc = [=[ 2799 Flatten {list} up to {maxdepth} levels. Without {maxdepth} 2800 the result is a |List| without nesting, as if {maxdepth} is 2801 a very large number. 2802 The {list} is changed in place, use |flattennew()| if you do 2803 not want that. 2804 *E900* 2805 {maxdepth} means how deep in nested lists changes are made. 2806 {list} is not modified when {maxdepth} is 0. 2807 {maxdepth} must be positive number. 2808 2809 If there is an error the number zero is returned. 2810 2811 Example: >vim 2812 echo flatten([1, [2, [3, 4]], 5]) 2813 < [1, 2, 3, 4, 5] >vim 2814 echo flatten([1, [2, [3, 4]], 5], 1) 2815 < [1, 2, [3, 4], 5] 2816 2817 ]=], 2818 name = 'flatten', 2819 params = { { 'list', 'any[]' }, { 'maxdepth', 'integer' } }, 2820 returns = 'any[]|0', 2821 signature = 'flatten({list} [, {maxdepth}])', 2822 }, 2823 flattennew = { 2824 args = { 1, 2 }, 2825 base = 1, 2826 desc = [=[ 2827 Like |flatten()| but first make a copy of {list}. 2828 ]=], 2829 name = 'flattennew', 2830 params = { { 'list', 'any[]' }, { 'maxdepth', 'integer' } }, 2831 returns = 'any[]|0', 2832 signature = 'flattennew({list} [, {maxdepth}])', 2833 }, 2834 float2nr = { 2835 args = 1, 2836 base = 1, 2837 desc = [=[ 2838 Convert {expr} to a Number by omitting the part after the 2839 decimal point. 2840 {expr} must evaluate to a |Float| or a |Number|. 2841 Returns 0 if {expr} is not a |Float| or a |Number|. 2842 When the value of {expr} is out of range for a |Number| the 2843 result is truncated to 0x7fffffff or -0x7fffffff (or when 2844 64-bit Number support is enabled, 0x7fffffffffffffff or 2845 -0x7fffffffffffffff). NaN results in -0x80000000 (or when 2846 64-bit Number support is enabled, -0x8000000000000000). 2847 Examples: >vim 2848 echo float2nr(3.95) 2849 < 3 >vim 2850 echo float2nr(-23.45) 2851 < -23 >vim 2852 echo float2nr(1.0e100) 2853 < 2147483647 (or 9223372036854775807) >vim 2854 echo float2nr(-1.0e150) 2855 < -2147483647 (or -9223372036854775807) >vim 2856 echo float2nr(1.0e-100) 2857 < 0 2858 2859 ]=], 2860 name = 'float2nr', 2861 params = { { 'expr', 'number' } }, 2862 signature = 'float2nr({expr})', 2863 }, 2864 floor = { 2865 args = 1, 2866 base = 1, 2867 desc = [=[ 2868 Return the largest integral value less than or equal to 2869 {expr} as a |Float| (round down). 2870 {expr} must evaluate to a |Float| or a |Number|. 2871 Returns 0.0 if {expr} is not a |Float| or a |Number|. 2872 Examples: >vim 2873 echo floor(1.856) 2874 < 1.0 >vim 2875 echo floor(-5.456) 2876 < -6.0 >vim 2877 echo floor(4.0) 2878 < 4.0 2879 2880 ]=], 2881 float_func = 'floor', 2882 name = 'floor', 2883 params = { { 'expr', 'number' } }, 2884 signature = 'floor({expr})', 2885 }, 2886 fmod = { 2887 args = 2, 2888 base = 1, 2889 desc = [=[ 2890 Return the remainder of {expr1} / {expr2}, even if the 2891 division is not representable. Returns {expr1} - i * {expr2} 2892 for some integer i such that if {expr2} is non-zero, the 2893 result has the same sign as {expr1} and magnitude less than 2894 the magnitude of {expr2}. If {expr2} is zero, the value 2895 returned is zero. The value returned is a |Float|. 2896 {expr1} and {expr2} must evaluate to a |Float| or a |Number|. 2897 Returns 0.0 if {expr1} or {expr2} is not a |Float| or a 2898 |Number|. 2899 Examples: >vim 2900 echo fmod(12.33, 1.22) 2901 < 0.13 >vim 2902 echo fmod(-12.33, 1.22) 2903 < -0.13 2904 2905 ]=], 2906 name = 'fmod', 2907 params = { { 'expr1', 'number' }, { 'expr2', 'number' } }, 2908 signature = 'fmod({expr1}, {expr2})', 2909 }, 2910 fnameescape = { 2911 args = 1, 2912 base = 1, 2913 desc = [=[ 2914 Escape {string} for use as file name command argument. All 2915 characters that have a special meaning, such as `'%'` and `'|'` 2916 are escaped with a backslash. For most systems the characters 2917 escaped are: > 2918 \t\n *?[{`$\\%#'\"|!< 2919 <For systems where a backslash appears in a filename, it 2920 depends on the value of 'isfname'. A leading '+' and '>' is 2921 also escaped (special after |:edit| and |:write|). And a "-" 2922 by itself (special after |:cd|). 2923 Returns an empty string on error. 2924 Example: >vim 2925 let fname = '+some str%nge|name' 2926 exe "edit " .. fnameescape(fname) 2927 <results in executing: >vim 2928 edit \+some\ str\%nge\|name 2929 < 2930 ]=], 2931 fast = true, 2932 name = 'fnameescape', 2933 params = { { 'string', 'string' } }, 2934 returns = 'string', 2935 signature = 'fnameescape({string})', 2936 }, 2937 fnamemodify = { 2938 args = 2, 2939 base = 1, 2940 desc = [=[ 2941 Modify file name {fname} according to {mods}. {mods} is a 2942 string of characters like it is used for file names on the 2943 command line. See |filename-modifiers|. 2944 Example: >vim 2945 echo fnamemodify("main.c", ":p:h") 2946 <results in: > 2947 /home/user/vim/vim/src 2948 <If {mods} is empty or an unsupported modifier is used then 2949 {fname} is returned. 2950 When {fname} is empty then with {mods} ":h" returns ".", so 2951 that `:cd` can be used with it. This is different from 2952 expand('%:h') without a buffer name, which returns an empty 2953 string. 2954 Note: Environment variables don't work in {fname}, use 2955 |expand()| first then. 2956 2957 ]=], 2958 fast = true, 2959 name = 'fnamemodify', 2960 params = { { 'fname', 'string' }, { 'mods', 'string' } }, 2961 returns = 'string', 2962 signature = 'fnamemodify({fname}, {mods})', 2963 }, 2964 foldclosed = { 2965 args = 1, 2966 base = 1, 2967 desc = [=[ 2968 The result is a Number. If the line {lnum} is in a closed 2969 fold, the result is the number of the first line in that fold. 2970 If the line {lnum} is not in a closed fold, -1 is returned. 2971 {lnum} is used like with |getline()|. Thus "." is the current 2972 line, "'m" mark m, etc. 2973 2974 ]=], 2975 name = 'foldclosed', 2976 params = { { 'lnum', 'integer|string' } }, 2977 returns = 'integer', 2978 signature = 'foldclosed({lnum})', 2979 }, 2980 foldclosedend = { 2981 args = 1, 2982 base = 1, 2983 desc = [=[ 2984 The result is a Number. If the line {lnum} is in a closed 2985 fold, the result is the number of the last line in that fold. 2986 If the line {lnum} is not in a closed fold, -1 is returned. 2987 {lnum} is used like with |getline()|. Thus "." is the current 2988 line, "'m" mark m, etc. 2989 2990 ]=], 2991 name = 'foldclosedend', 2992 params = { { 'lnum', 'integer|string' } }, 2993 returns = 'integer', 2994 signature = 'foldclosedend({lnum})', 2995 }, 2996 foldlevel = { 2997 args = 1, 2998 base = 1, 2999 desc = [=[ 3000 The result is a Number, which is the foldlevel of line {lnum} 3001 in the current buffer. For nested folds the deepest level is 3002 returned. If there is no fold at line {lnum}, zero is 3003 returned. It doesn't matter if the folds are open or closed. 3004 When used while updating folds (from 'foldexpr') -1 is 3005 returned for lines where folds are still to be updated and the 3006 foldlevel is unknown. As a special case the level of the 3007 previous line is usually available. 3008 {lnum} is used like with |getline()|. Thus "." is the current 3009 line, "'m" mark m, etc. 3010 3011 ]=], 3012 name = 'foldlevel', 3013 params = { { 'lnum', 'integer|string' } }, 3014 returns = 'integer', 3015 signature = 'foldlevel({lnum})', 3016 }, 3017 foldtext = { 3018 desc = [=[ 3019 Returns a String, to be displayed for a closed fold. This is 3020 the default function used for the 'foldtext' option and should 3021 only be called from evaluating 'foldtext'. It uses the 3022 |v:foldstart|, |v:foldend| and |v:folddashes| variables. 3023 The returned string looks like this: > 3024 +-- 45 lines: abcdef 3025 <The number of leading dashes depends on the foldlevel. The 3026 "45" is the number of lines in the fold. "abcdef" is the text 3027 in the first non-blank line of the fold. Leading white space, 3028 "//" or "/*" and the text from the 'foldmarker' and 3029 'commentstring' options is removed. 3030 When used to draw the actual foldtext, the rest of the line 3031 will be filled with the fold char from the 'fillchars' 3032 setting. 3033 Returns an empty string when there is no fold. 3034 ]=], 3035 name = 'foldtext', 3036 params = {}, 3037 returns = 'string', 3038 signature = 'foldtext()', 3039 }, 3040 foldtextresult = { 3041 args = 1, 3042 base = 1, 3043 desc = [=[ 3044 Returns the text that is displayed for the closed fold at line 3045 {lnum}. Evaluates 'foldtext' in the appropriate context. 3046 When there is no closed fold at {lnum} an empty string is 3047 returned. 3048 {lnum} is used like with |getline()|. Thus "." is the current 3049 line, "'m" mark m, etc. 3050 Useful when exporting folded text, e.g., to HTML. 3051 3052 ]=], 3053 name = 'foldtextresult', 3054 params = { { 'lnum', 'integer|string' } }, 3055 returns = 'string', 3056 signature = 'foldtextresult({lnum})', 3057 }, 3058 foreach = { 3059 args = 2, 3060 base = 1, 3061 desc = [=[ 3062 {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. 3063 For each item in {expr1} execute {expr2}. {expr1} is not 3064 modified; its values may be, as with |:lockvar| 1. |E741| 3065 See |map()| and |filter()| to modify {expr1}. 3066 3067 {expr2} must be a |string| or |Funcref|. 3068 3069 If {expr2} is a |string|, inside {expr2} |v:val| has the value 3070 of the current item. For a |Dictionary| |v:key| has the key 3071 of the current item and for a |List| |v:key| has the index of 3072 the current item. For a |Blob| |v:key| has the index of the 3073 current byte. For a |String| |v:key| has the index of the 3074 current character. 3075 Examples: >vim 3076 call foreach(mylist, 'let used[v:val] = v:true') 3077 <This records the items that are in the {expr1} list. 3078 3079 Note that {expr2} is the result of expression and is then used 3080 as a command. Often it is good to use a |literal-string| to 3081 avoid having to double backslashes. 3082 3083 If {expr2} is a |Funcref| it must take two arguments: 3084 1. the key or the index of the current item. 3085 2. the value of the current item. 3086 With a lambda you don't get an error if it only accepts one 3087 argument. 3088 If the function returns a value, it is ignored. 3089 3090 Returns {expr1} in all cases. 3091 When an error is encountered while executing {expr2} no 3092 further items in {expr1} are processed. 3093 When {expr2} is a Funcref errors inside a function are 3094 ignored, unless it was defined with the "abort" flag. 3095 ]=], 3096 name = 'foreach', 3097 params = { { 'expr1', 'string|table' }, { 'expr2', 'string|function' } }, 3098 returns = 'string|table', 3099 signature = 'foreach({expr1}, {expr2})', 3100 }, 3101 foreground = { 3102 args = 0, 3103 params = {}, 3104 lua = false, 3105 }, 3106 fullcommand = { 3107 args = 1, 3108 base = 1, 3109 desc = [=[ 3110 Get the full command name from a short abbreviated command 3111 name; see |20.2| for details on command abbreviations. 3112 3113 The string argument {name} may start with a `:` and can 3114 include a [range], these are skipped and not returned. 3115 Returns an empty string if a command doesn't exist or if it's 3116 ambiguous (for user-defined commands). 3117 3118 For example `fullcommand('s')`, `fullcommand('sub')`, 3119 `fullcommand(':%substitute')` all return "substitute". 3120 3121 ]=], 3122 name = 'fullcommand', 3123 params = { { 'name', 'string' } }, 3124 returns = 'string', 3125 signature = 'fullcommand({name})', 3126 }, 3127 funcref = { 3128 args = { 1, 3 }, 3129 base = 1, 3130 desc = [=[ 3131 Just like |function()|, but the returned Funcref will lookup 3132 the function by reference, not by name. This matters when the 3133 function {name} is redefined later. 3134 3135 Unlike |function()|, {name} must be an existing user function. 3136 It only works for an autoloaded function if it has already 3137 been loaded (to avoid mistakenly loading the autoload script 3138 when only intending to use the function name, use |function()| 3139 instead). {name} cannot be a builtin function. 3140 Returns 0 on error. 3141 3142 ]=], 3143 name = 'funcref', 3144 params = { { 'name', 'string' }, { 'arglist', 'any' }, { 'dict', 'any' } }, 3145 signature = 'funcref({name} [, {arglist}] [, {dict}])', 3146 }, 3147 ['function'] = { 3148 args = { 1, 3 }, 3149 base = 1, 3150 desc = [=[ 3151 Return a |Funcref| variable that refers to function {name}. 3152 {name} can be the name of a user defined function or an 3153 internal function. 3154 3155 {name} can also be a Funcref or a partial. When it is a 3156 partial the dict stored in it will be used and the {dict} 3157 argument is not allowed. E.g.: >vim 3158 let FuncWithArg = function(dict.Func, [arg]) 3159 let Broken = function(dict.Func, [arg], dict) 3160 < 3161 When using the Funcref the function will be found by {name}, 3162 also when it was redefined later. Use |funcref()| to keep the 3163 same function. 3164 3165 When {arglist} or {dict} is present this creates a partial. 3166 That means the argument list and/or the dictionary is stored 3167 in the Funcref and will be used when the Funcref is called. 3168 3169 The arguments are passed to the function in front of other 3170 arguments, but after any argument from |method|. Example: >vim 3171 func Callback(arg1, arg2, name) 3172 "... 3173 endfunc 3174 let Partial = function('Callback', ['one', 'two']) 3175 "... 3176 call Partial('name') 3177 <Invokes the function as with: >vim 3178 call Callback('one', 'two', 'name') 3179 3180 <With a |method|: >vim 3181 func Callback(one, two, three) 3182 "... 3183 endfunc 3184 let Partial = function('Callback', ['two']) 3185 "... 3186 eval 'one'->Partial('three') 3187 <Invokes the function as with: >vim 3188 call Callback('one', 'two', 'three') 3189 3190 <The function() call can be nested to add more arguments to the 3191 Funcref. The extra arguments are appended to the list of 3192 arguments. Example: >vim 3193 func Callback(arg1, arg2, name) 3194 "... 3195 endfunc 3196 let Func = function('Callback', ['one']) 3197 let Func2 = function(Func, ['two']) 3198 "... 3199 call Func2('name') 3200 <Invokes the function as with: >vim 3201 call Callback('one', 'two', 'name') 3202 3203 <The Dictionary is only useful when calling a "dict" function. 3204 In that case the {dict} is passed in as "self". Example: >vim 3205 function Callback() dict 3206 echo "called for " .. self.name 3207 endfunction 3208 "... 3209 let context = {"name": "example"} 3210 let Func = function('Callback', context) 3211 "... 3212 call Func() " will echo: called for example 3213 <The use of function() is not needed when there are no extra 3214 arguments, these two are equivalent, if Callback() is defined 3215 as context.Callback(): >vim 3216 let Func = function('Callback', context) 3217 let Func = context.Callback 3218 3219 <The argument list and the Dictionary can be combined: >vim 3220 function Callback(arg1, count) dict 3221 "... 3222 endfunction 3223 let context = {"name": "example"} 3224 let Func = function('Callback', ['one'], context) 3225 "... 3226 call Func(500) 3227 <Invokes the function as with: >vim 3228 call context.Callback('one', 500) 3229 < 3230 Returns 0 on error. 3231 3232 ]=], 3233 name = 'function', 3234 params = { { 'name', 'string' }, { 'arglist', 'any' }, { 'dict', 'any' } }, 3235 signature = 'function({name} [, {arglist}] [, {dict}])', 3236 tags = { 'partial', 'E700', 'E923' }, 3237 }, 3238 garbagecollect = { 3239 args = { 0, 1 }, 3240 desc = [=[ 3241 Cleanup unused |Lists| and |Dictionaries| that have circular 3242 references. 3243 3244 There is hardly ever a need to invoke this function, as it is 3245 automatically done when Vim runs out of memory or is waiting 3246 for the user to press a key after 'updatetime'. Items without 3247 circular references are always freed when they become unused. 3248 This is useful if you have deleted a very big |List| and/or 3249 |Dictionary| with circular references in a script that runs 3250 for a long time. 3251 3252 When the optional {atexit} argument is one, garbage 3253 collection will also be done when exiting Vim, if it wasn't 3254 done before. This is useful when checking for memory leaks. 3255 3256 The garbage collection is not done immediately but only when 3257 it's safe to perform. This is when waiting for the user to 3258 type a character. 3259 ]=], 3260 name = 'garbagecollect', 3261 params = { { 'atexit', 'boolean' } }, 3262 signature = 'garbagecollect([{atexit}])', 3263 }, 3264 get = { 3265 args = { 2, 3 }, 3266 base = 1, 3267 desc = [=[ 3268 Get item {idx} from |List| {list}. When this item is not 3269 available return {default}. Return zero when {default} is 3270 omitted. 3271 ]=], 3272 name = 'get', 3273 params = { { 'list', 'any[]' }, { 'idx', 'integer' }, { 'default', 'any' } }, 3274 signature = 'get({list}, {idx} [, {default}])', 3275 tags = { 'get()-list' }, 3276 }, 3277 get__1 = { 3278 args = { 2, 3 }, 3279 base = 1, 3280 desc = [=[ 3281 Get byte {idx} from |Blob| {blob}. When this byte is not 3282 available return {default}. Return -1 when {default} is 3283 omitted. 3284 ]=], 3285 name = 'get', 3286 params = { { 'blob', 'string' }, { 'idx', 'integer' }, { 'default', 'any' } }, 3287 signature = 'get({blob}, {idx} [, {default}])', 3288 tags = { 'get()-blob' }, 3289 }, 3290 get__2 = { 3291 args = { 2, 3 }, 3292 base = 1, 3293 desc = [=[ 3294 Get item with key {key} from |Dictionary| {dict}. When this 3295 item is not available return {default}. Return zero when 3296 {default} is omitted. Useful example: >vim 3297 let val = get(g:, 'var_name', 'default') 3298 <This gets the value of g:var_name if it exists, and uses 3299 "default" when it does not exist. 3300 ]=], 3301 name = 'get', 3302 params = { { 'dict', 'table<string,any>' }, { 'key', 'string' }, { 'default', 'any' } }, 3303 signature = 'get({dict}, {key} [, {default}])', 3304 tags = { 'get()-dict' }, 3305 }, 3306 get__3 = { 3307 args = { 2, 3 }, 3308 base = 1, 3309 desc = [=[ 3310 Get item {what} from |Funcref| {func}. Possible values for 3311 {what} are: 3312 "name" The function name 3313 "func" The function 3314 "dict" The dictionary 3315 "args" The list with arguments 3316 "arity" A dictionary with information about the number of 3317 arguments accepted by the function (minus the 3318 {arglist}) with the following fields: 3319 required the number of positional arguments 3320 optional the number of optional arguments, 3321 in addition to the required ones 3322 varargs |TRUE| if the function accepts a 3323 variable number of arguments |...| 3324 3325 Note: There is no error, if the {arglist} of 3326 the Funcref contains more arguments than the 3327 Funcref expects, it's not validated. 3328 3329 Returns zero on error. 3330 ]=], 3331 name = 'get', 3332 params = { { 'func', 'function' }, { 'what', 'string' } }, 3333 returns = 'any', 3334 signature = 'get({func}, {what})', 3335 tags = { 'get()-func' }, 3336 }, 3337 getbufinfo = { 3338 args = { 0, 1 }, 3339 base = 1, 3340 name = 'getbufinfo', 3341 params = { { 'buf', 'integer|string' } }, 3342 signature = 'getbufinfo([{buf}])', 3343 returns = 'vim.fn.getbufinfo.ret.item[]', 3344 }, 3345 getbufinfo__1 = { 3346 args = { 0, 1 }, 3347 base = 1, 3348 desc = [=[ 3349 Get information about buffers as a List of Dictionaries. 3350 3351 Without an argument information about all the buffers is 3352 returned. 3353 3354 When the argument is a |Dictionary| only the buffers matching 3355 the specified criteria are returned. The following keys can 3356 be specified in {dict}: 3357 buflisted include only listed buffers. 3358 bufloaded include only loaded buffers. 3359 bufmodified include only modified buffers. 3360 3361 Otherwise, {buf} specifies a particular buffer to return 3362 information for. For the use of {buf}, see |bufname()| 3363 above. If the buffer is found the returned List has one item. 3364 Otherwise the result is an empty list. 3365 3366 Each returned List item is a dictionary with the following 3367 entries: 3368 bufnr Buffer number. 3369 changed TRUE if the buffer is modified. 3370 changedtick Number of changes made to the buffer. 3371 command TRUE if the buffer belongs to the 3372 command-line window |cmdwin|. 3373 hidden TRUE if the buffer is hidden. 3374 lastused Timestamp in seconds, like 3375 |localtime()|, when the buffer was 3376 last used. 3377 listed TRUE if the buffer is listed. 3378 lnum Line number used for the buffer when 3379 opened in the current window. 3380 Only valid if the buffer has been 3381 displayed in the window in the past. 3382 If you want the line number of the 3383 last known cursor position in a given 3384 window, use |line()|: >vim 3385 echo line('.', {winid}) 3386 < 3387 linecount Number of lines in the buffer (only 3388 valid when loaded) 3389 loaded TRUE if the buffer is loaded. 3390 name Full path to the file in the buffer. 3391 signs List of signs placed in the buffer. 3392 Each list item is a dictionary with 3393 the following fields: 3394 id sign identifier 3395 lnum line number 3396 name sign name 3397 variables A reference to the dictionary with 3398 buffer-local variables. 3399 windows List of |window-ID|s that display this 3400 buffer 3401 3402 Examples: >vim 3403 for buf in getbufinfo() 3404 echo buf.name 3405 endfor 3406 for buf in getbufinfo({'buflisted':1}) 3407 if buf.changed 3408 " .... 3409 endif 3410 endfor 3411 < 3412 To get buffer-local options use: >vim 3413 getbufvar({bufnr}, '&option_name') 3414 < 3415 ]=], 3416 name = 'getbufinfo', 3417 params = { { 'dict', 'vim.fn.getbufinfo.dict' } }, 3418 signature = 'getbufinfo([{dict}])', 3419 returns = 'vim.fn.getbufinfo.ret.item[]', 3420 }, 3421 getbufline = { 3422 args = { 2, 3 }, 3423 base = 1, 3424 desc = [=[ 3425 Return a |List| with the lines starting from {lnum} to {end} 3426 (inclusive) in the buffer {buf}. If {end} is omitted, a 3427 |List| with only the line {lnum} is returned. See 3428 `getbufoneline()` for only getting the line. 3429 3430 For the use of {buf}, see |bufname()| above. 3431 3432 For {lnum} and {end} "$" can be used for the last line of the 3433 buffer. Otherwise a number must be used. 3434 3435 When {lnum} is smaller than 1 or bigger than the number of 3436 lines in the buffer, an empty |List| is returned. 3437 3438 When {end} is greater than the number of lines in the buffer, 3439 it is treated as {end} is set to the number of lines in the 3440 buffer. When {end} is before {lnum} an empty |List| is 3441 returned. 3442 3443 This function works only for loaded buffers. For unloaded and 3444 non-existing buffers, an empty |List| is returned. 3445 3446 Example: >vim 3447 let lines = getbufline(bufnr("myfile"), 1, "$") 3448 < 3449 3450 ]=], 3451 name = 'getbufline', 3452 params = { { 'buf', 'integer|string' }, { 'lnum', 'integer' }, { 'end', 'integer' } }, 3453 returns = 'string[]', 3454 signature = 'getbufline({buf}, {lnum} [, {end}])', 3455 }, 3456 getbufoneline = { 3457 args = 2, 3458 base = 1, 3459 desc = [=[ 3460 Just like `getbufline()` but only get one line and return it 3461 as a string. 3462 ]=], 3463 name = 'getbufoneline', 3464 params = { { 'buf', 'integer|string' }, { 'lnum', 'integer' } }, 3465 signature = 'getbufoneline({buf}, {lnum})', 3466 returns = 'string', 3467 }, 3468 getbufvar = { 3469 args = { 2, 3 }, 3470 base = 1, 3471 desc = [=[ 3472 The result is the value of option or local buffer variable 3473 {varname} in buffer {buf}. Note that the name without "b:" 3474 must be used. 3475 The {varname} argument is a string. 3476 When {varname} is empty returns a |Dictionary| with all the 3477 buffer-local variables. 3478 When {varname} is equal to "&" returns a |Dictionary| with all 3479 the buffer-local options. 3480 Otherwise, when {varname} starts with "&" returns the value of 3481 a buffer-local option. 3482 This also works for a global or buffer-local option, but it 3483 doesn't work for a global variable, window-local variable or 3484 window-local option. 3485 For the use of {buf}, see |bufname()| above. 3486 When the buffer or variable doesn't exist {def} or an empty 3487 string is returned, there is no error message. 3488 Examples: >vim 3489 let bufmodified = getbufvar(1, "&mod") 3490 echo "todo myvar = " .. getbufvar("todo", "myvar") 3491 < 3492 ]=], 3493 name = 'getbufvar', 3494 params = { { 'buf', 'integer|string' }, { 'varname', 'string' }, { 'def', 'any' } }, 3495 signature = 'getbufvar({buf}, {varname} [, {def}])', 3496 }, 3497 getcellwidths = { 3498 desc = [=[ 3499 Returns a |List| of cell widths of character ranges overridden 3500 by |setcellwidths()|. The format is equal to the argument of 3501 |setcellwidths()|. If no character ranges have their cell 3502 widths overridden, an empty List is returned. 3503 ]=], 3504 name = 'getcellwidths', 3505 params = {}, 3506 signature = 'getcellwidths()', 3507 }, 3508 getchangelist = { 3509 args = { 0, 1 }, 3510 base = 1, 3511 desc = [=[ 3512 Returns the |changelist| for the buffer {buf}. For the use 3513 of {buf}, see |bufname()| above. If buffer {buf} doesn't 3514 exist, an empty list is returned. 3515 3516 The returned list contains two entries: a list with the change 3517 locations and the current position in the list. Each 3518 entry in the change list is a dictionary with the following 3519 entries: 3520 col column number 3521 coladd column offset for 'virtualedit' 3522 lnum line number 3523 If buffer {buf} is the current buffer, then the current 3524 position refers to the position in the list. For other 3525 buffers, it is set to the length of the list. 3526 3527 ]=], 3528 name = 'getchangelist', 3529 params = { { 'buf', 'integer|string' } }, 3530 returns = 'table[]', 3531 signature = 'getchangelist([{buf}])', 3532 }, 3533 getchar = { 3534 args = { 0, 2 }, 3535 desc = [=[ 3536 Get a single character from the user or input stream. 3537 If {expr} is omitted or is -1, wait until a character is 3538 available. 3539 If {expr} is 0, only get a character when one is available. 3540 Return zero otherwise. 3541 If {expr} is 1, only check if a character is available, it is 3542 not consumed. Return zero if no character available. 3543 To always get a string, specify "number" as |FALSE| in {opts}. 3544 3545 Without {expr} and when {expr} is 0 a whole character or 3546 special key is returned. If it is a single character, the 3547 result is a Number. Use |nr2char()| to convert it to a String. 3548 Otherwise a String is returned with the encoded character. 3549 For a special key it's a String with a sequence of bytes 3550 starting with 0x80 (decimal: 128). This is the same value as 3551 the String "\<Key>", e.g., "\<Left>". The returned value is 3552 also a String when a modifier (shift, control, alt) was used 3553 that is not included in the character. |keytrans()| can also 3554 be used to convert a returned String into a readable form. 3555 3556 When {expr} is 0 and Esc is typed, there will be a short delay 3557 while Vim waits to see if this is the start of an escape 3558 sequence. 3559 3560 When {expr} is 1 only the first byte is returned. For a 3561 one-byte character it is the character itself as a number. 3562 Use |nr2char()| to convert it to a String. 3563 3564 Use |getcharmod()| to obtain any additional modifiers. 3565 3566 The optional argument {opts} is a Dict and supports the 3567 following items: 3568 3569 cursor A String specifying cursor behavior 3570 when waiting for a character. 3571 "hide": hide the cursor. 3572 "keep": keep current cursor unchanged. 3573 "msg": move cursor to message area. 3574 (default: automagically decide 3575 between "keep" and "msg") 3576 3577 number If |TRUE|, return a Number when getting 3578 a single character. 3579 If |FALSE|, the return value is always 3580 converted to a String, and an empty 3581 String (instead of 0) is returned when 3582 no character is available. 3583 (default: |TRUE|) 3584 3585 simplify If |TRUE|, include modifiers in the 3586 character if possible. E.g., return 3587 the same value for CTRL-I and <Tab>. 3588 If |FALSE|, don't include modifiers in 3589 the character. 3590 (default: |TRUE|) 3591 3592 When the user clicks a mouse button, the mouse event will be 3593 returned. The position can then be found in |v:mouse_col|, 3594 |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|. 3595 |getmousepos()| can also be used. Mouse move events will be 3596 ignored. 3597 This example positions the mouse as it would normally happen: >vim 3598 let c = getchar() 3599 if c == "\<LeftMouse>" && v:mouse_win > 0 3600 exe v:mouse_win .. "wincmd w" 3601 exe v:mouse_lnum 3602 exe "normal " .. v:mouse_col .. "|" 3603 endif 3604 < 3605 There is no prompt, you will somehow have to make clear to the 3606 user that a character has to be typed. The screen is not 3607 redrawn, e.g. when resizing the window. 3608 3609 There is no mapping for the character. 3610 Key codes are replaced, thus when the user presses the <Del> 3611 key you get the code for the <Del> key, not the raw character 3612 sequence. Examples: >vim 3613 getchar() == "\<Del>" 3614 getchar() == "\<S-Left>" 3615 <This example redefines "f" to ignore case: >vim 3616 nmap f :call FindChar()<CR> 3617 function FindChar() 3618 let c = nr2char(getchar()) 3619 while col('.') < col('$') - 1 3620 normal l 3621 if getline('.')[col('.') - 1] ==? c 3622 break 3623 endif 3624 endwhile 3625 endfunction 3626 < 3627 ]=], 3628 name = 'getchar', 3629 params = { { 'expr', '-1|0|1' }, { 'opts', 'table' } }, 3630 returns = 'integer|string', 3631 signature = 'getchar([{expr} [, {opts}]])', 3632 }, 3633 getcharmod = { 3634 desc = [=[ 3635 The result is a Number which is the state of the modifiers for 3636 the last obtained character with |getchar()| or in another way. 3637 These values are added together: 3638 2 shift 3639 4 control 3640 8 alt (meta) 3641 16 meta (when it's different from ALT) 3642 32 mouse double click 3643 64 mouse triple click 3644 96 mouse quadruple click (== 32 + 64) 3645 128 command (Mac) or super 3646 Only the modifiers that have not been included in the 3647 character itself are obtained. Thus Shift-a results in "A" 3648 without a modifier. Returns 0 if no modifiers are used. 3649 ]=], 3650 name = 'getcharmod', 3651 params = {}, 3652 returns = 'integer', 3653 signature = 'getcharmod()', 3654 }, 3655 getcharpos = { 3656 args = 1, 3657 base = 1, 3658 desc = [=[ 3659 Get the position for String {expr}. Same as |getpos()| but the 3660 column number in the returned List is a character index 3661 instead of a byte index. 3662 If |getpos()| returns a very large column number, equal to 3663 |v:maxcol|, then getcharpos() will return the character index 3664 of the last character. 3665 3666 Example: 3667 With the cursor on '세' in line 5 with text "여보세요": >vim 3668 getcharpos('.') returns [0, 5, 3, 0] 3669 getpos('.') returns [0, 5, 7, 0] 3670 < 3671 ]=], 3672 name = 'getcharpos', 3673 params = { { 'expr', 'string' } }, 3674 returns = 'integer[]', 3675 signature = 'getcharpos({expr})', 3676 }, 3677 getcharsearch = { 3678 desc = [=[ 3679 Return the current character search information as a {dict} 3680 with the following entries: 3681 3682 char character previously used for a character 3683 search (|t|, |f|, |T|, or |F|); empty string 3684 if no character search has been performed 3685 forward direction of character search; 1 for forward, 3686 0 for backward 3687 until type of character search; 1 for a |t| or |T| 3688 character search, 0 for an |f| or |F| 3689 character search 3690 3691 This can be useful to always have |;| and |,| search 3692 forward/backward regardless of the direction of the previous 3693 character search: >vim 3694 nnoremap <expr> ; getcharsearch().forward ? ';' : ',' 3695 nnoremap <expr> , getcharsearch().forward ? ',' : ';' 3696 <Also see |setcharsearch()|. 3697 ]=], 3698 name = 'getcharsearch', 3699 params = {}, 3700 returns = '{ char: string, forward: 1|0, until: 1|0 }', 3701 signature = 'getcharsearch()', 3702 }, 3703 getcharstr = { 3704 args = { 0, 2 }, 3705 desc = [=[ 3706 The same as |getchar()|, except that this always returns a 3707 String, and "number" isn't allowed in {opts}. 3708 ]=], 3709 name = 'getcharstr', 3710 params = { { 'expr', '-1|0|1' }, { 'opts', 'table' } }, 3711 returns = 'string', 3712 signature = 'getcharstr([{expr} [, {opts}]])', 3713 }, 3714 getcmdcomplpat = { 3715 desc = [=[ 3716 Return completion pattern of the current command-line. 3717 Only works when the command line is being edited, thus 3718 requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. 3719 Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, 3720 |getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|. 3721 Returns an empty string when completion is not defined. 3722 ]=], 3723 name = 'getcmdcomplpat', 3724 params = {}, 3725 returns = 'string', 3726 signature = 'getcmdcomplpat()', 3727 }, 3728 getcmdcompltype = { 3729 desc = [=[ 3730 Return the type of the current command-line completion. 3731 Only works when the command line is being edited, thus 3732 requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. 3733 See |:command-completion| for the return string. 3734 Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, 3735 |getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|. 3736 Returns an empty string when completion is not defined. 3737 3738 To get the type of the command-line completion for a specified 3739 string, use |getcompletiontype()|. 3740 ]=], 3741 name = 'getcmdcompltype', 3742 params = {}, 3743 returns = 'string', 3744 signature = 'getcmdcompltype()', 3745 }, 3746 getcmdline = { 3747 desc = [=[ 3748 Return the current command-line input. Only works when the 3749 command line is being edited, thus requires use of 3750 |c_CTRL-\_e| or |c_CTRL-R_=|. 3751 Example: >vim 3752 cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR> 3753 <Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|, 3754 |getcmdprompt()| and |setcmdline()|. 3755 Returns an empty string when entering a password or using 3756 |inputsecret()|. 3757 ]=], 3758 name = 'getcmdline', 3759 params = {}, 3760 returns = 'string', 3761 signature = 'getcmdline()', 3762 }, 3763 getcmdpos = { 3764 desc = [=[ 3765 Return the position of the cursor in the command line as a 3766 byte count. The first column is 1. 3767 Only works when editing the command line, thus requires use of 3768 |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. 3769 Returns 0 otherwise. 3770 Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, 3771 |getcmdprompt()| and |setcmdline()|. 3772 ]=], 3773 name = 'getcmdpos', 3774 params = {}, 3775 returns = 'integer', 3776 signature = 'getcmdpos()', 3777 }, 3778 getcmdprompt = { 3779 desc = [=[ 3780 Return the current command-line prompt when using functions 3781 like |input()| or |confirm()|. 3782 Only works when the command line is being edited, thus 3783 requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. 3784 Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|, 3785 |setcmdpos()| and |setcmdline()|. 3786 ]=], 3787 name = 'getcmdprompt', 3788 params = {}, 3789 returns = 'string', 3790 signature = 'getcmdprompt()', 3791 }, 3792 getcmdscreenpos = { 3793 desc = [=[ 3794 Return the screen position of the cursor in the command line 3795 as a byte count. The first column is 1. 3796 Instead of |getcmdpos()|, it adds the prompt position. 3797 Only works when editing the command line, thus requires use of 3798 |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. 3799 Returns 0 otherwise. 3800 Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and 3801 |setcmdline()|. 3802 ]=], 3803 name = 'getcmdscreenpos', 3804 params = {}, 3805 returns = 'integer', 3806 signature = 'getcmdscreenpos()', 3807 }, 3808 getcmdtype = { 3809 desc = [=[ 3810 Return the current command-line type. Possible return values 3811 are: 3812 : normal Ex command 3813 > debug mode command |debug-mode| 3814 / forward search command 3815 ? backward search command 3816 @ |input()| command 3817 `-` |:insert| or |:append| command 3818 = |i_CTRL-R_=| 3819 Only works when editing the command line, thus requires use of 3820 |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. 3821 Returns an empty string otherwise. 3822 Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|. 3823 ]=], 3824 name = 'getcmdtype', 3825 params = {}, 3826 returns = "':'|'>'|'/'|'?'|'@'|'-'|'='|''", 3827 signature = 'getcmdtype()', 3828 }, 3829 getcmdwintype = { 3830 desc = [=[ 3831 Return the current |command-line-window| type. Possible return 3832 values are the same as |getcmdtype()|. Returns an empty string 3833 when not in the command-line window. 3834 ]=], 3835 name = 'getcmdwintype', 3836 params = {}, 3837 returns = "':'|'>'|'/'|'?'|'@'|'-'|'='|''", 3838 signature = 'getcmdwintype()', 3839 }, 3840 getcompletion = { 3841 args = { 2, 3 }, 3842 base = 1, 3843 desc = [=[ 3844 Return a list of command-line completion matches. The String 3845 {type} argument specifies what for. The following completion 3846 types are supported: 3847 3848 arglist file names in argument list 3849 augroup autocmd groups 3850 buffer buffer names 3851 breakpoint |:breakadd| and |:breakdel| suboptions 3852 cmdline |cmdline-completion| result 3853 color color schemes 3854 command Ex command 3855 compiler compilers 3856 custom,{func} custom completion, defined via {func} 3857 customlist,{func} custom completion, defined via {func} 3858 diff_buffer |:diffget| and |:diffput| completion 3859 dir directory names 3860 dir_in_path directory names in 'cdpath' 3861 environment environment variable names 3862 event autocommand events 3863 expression Vim expression 3864 file file and directory names 3865 file_in_path file and directory names in 'path' 3866 filetype filetype names 'filetype' 3867 filetypecmd |:filetype| suboptions 3868 function function name 3869 help help subjects 3870 highlight highlight groups 3871 history |:history| suboptions 3872 keymap keyboard mappings 3873 locale locale names (as output of locale -a) 3874 mapclear buffer argument 3875 mapping mapping name 3876 menu menus 3877 messages |:messages| suboptions 3878 option options 3879 packadd optional package |pack-add| names 3880 retab |:retab| suboptions 3881 runtime |:runtime| completion 3882 scriptnames sourced script names |:scriptnames| 3883 shellcmd Shell command 3884 shellcmdline Shell command line with filename arguments 3885 sign |:sign| suboptions 3886 syntax syntax file names 'syntax' 3887 syntime |:syntime| suboptions 3888 tag tags 3889 tag_listfiles tags, file names 3890 user user names 3891 var user variables 3892 3893 If {pat} is an empty string, then all the matches are 3894 returned. Otherwise only items matching {pat} are returned. 3895 See |wildcards| for the use of special characters in {pat}. 3896 3897 If the optional {filtered} flag is set to 1, then 'wildignore' 3898 is applied to filter the results. Otherwise all the matches 3899 are returned. The 'wildignorecase' option always applies. 3900 3901 If the 'wildoptions' option contains "fuzzy", then fuzzy 3902 matching is used to get the completion matches. Otherwise 3903 regular expression matching is used. Thus this function 3904 follows the user preference, what happens on the command line. 3905 If you do not want this you can make 'wildoptions' empty 3906 before calling getcompletion() and restore it afterwards. 3907 3908 If {type} is "cmdline", then the |cmdline-completion| result is 3909 returned. For example, to complete the possible values after 3910 a ":call" command: >vim 3911 echo getcompletion('call ', 'cmdline') 3912 < 3913 If there are no matches, an empty list is returned. An 3914 invalid value for {type} produces an error. 3915 3916 ]=], 3917 name = 'getcompletion', 3918 params = { { 'pat', 'string' }, { 'type', 'string' }, { 'filtered', 'boolean' } }, 3919 returns = 'string[]', 3920 signature = 'getcompletion({pat}, {type} [, {filtered}])', 3921 }, 3922 getcompletiontype = { 3923 args = 1, 3924 base = 1, 3925 desc = [=[ 3926 Return the type of the command-line completion using {pat}. 3927 When no corresponding completion type is found, an empty 3928 string is returned. 3929 To get the current command-line completion type, use 3930 |getcmdcompltype()|. 3931 ]=], 3932 name = 'getcompletiontype', 3933 params = { { 'pat', 'string' } }, 3934 returns = 'string', 3935 signature = 'getcompletiontype({pat})', 3936 }, 3937 getcurpos = { 3938 args = { 0, 1 }, 3939 base = 1, 3940 desc = [=[ 3941 Get the position of the cursor. This is like getpos('.'), but 3942 includes an extra "curswant" item in the list: 3943 [0, lnum, col, off, curswant] ~ 3944 The "curswant" number is the preferred column when moving the 3945 cursor vertically. After |$| command it will be a very large 3946 number equal to |v:maxcol|. Also see |getcursorcharpos()| and 3947 |getpos()|. 3948 The first "bufnum" item is always zero. The byte position of 3949 the cursor is returned in "col". To get the character 3950 position, use |getcursorcharpos()|. 3951 3952 The optional {winid} argument can specify the window. It can 3953 be the window number or the |window-ID|. The last known 3954 cursor position is returned, this may be invalid for the 3955 current value of the buffer if it is not the current window. 3956 If {winid} is invalid a list with zeroes is returned. 3957 3958 This can be used to save and restore the cursor position: >vim 3959 let save_cursor = getcurpos() 3960 MoveTheCursorAround 3961 call setpos('.', save_cursor) 3962 <Note that this only works within the window. See 3963 |winrestview()| for restoring more state. 3964 3965 ]=], 3966 name = 'getcurpos', 3967 params = { { 'winid', 'integer' } }, 3968 returns = '[integer, integer, integer, integer, integer]', 3969 signature = 'getcurpos([{winid}])', 3970 }, 3971 getcursorcharpos = { 3972 args = { 0, 1 }, 3973 base = 1, 3974 desc = [=[ 3975 Same as |getcurpos()| but the column number in the returned 3976 List is a character index instead of a byte index. 3977 3978 Example: 3979 With the cursor on '보' in line 3 with text "여보세요": >vim 3980 getcursorcharpos() " returns [0, 3, 2, 0, 3] 3981 getcurpos() " returns [0, 3, 4, 0, 3] 3982 < 3983 ]=], 3984 name = 'getcursorcharpos', 3985 params = { { 'winid', 'integer' } }, 3986 signature = 'getcursorcharpos([{winid}])', 3987 }, 3988 getcwd = { 3989 args = { 0, 2 }, 3990 base = 1, 3991 desc = [=[ 3992 With no arguments, returns the name of the effective 3993 |current-directory|. With {winnr} or {tabnr} the working 3994 directory of that scope is returned, and 'autochdir' is 3995 ignored. Tabs and windows are identified by their respective 3996 numbers, 0 means current tab or window. Missing tab number 3997 implies 0. Thus the following are equivalent: >vim 3998 getcwd(0) 3999 getcwd(0, 0) 4000 <If {winnr} is -1 it is ignored, only the tab is resolved. 4001 {winnr} can be the window number or the |window-ID|. 4002 If both {winnr} and {tabnr} are -1 the global working 4003 directory is returned. 4004 Note: When {tabnr} is -1 Vim returns an empty string to 4005 signal that it is invalid, whereas Nvim returns either the 4006 global working directory if {winnr} is -1 or the working 4007 directory of the window indicated by {winnr}. 4008 Throw error if the arguments are invalid. |E5000| |E5001| |E5002| 4009 4010 ]=], 4011 name = 'getcwd', 4012 params = { { 'winnr', 'integer' }, { 'tabnr', 'integer' } }, 4013 returns = 'string', 4014 signature = 'getcwd([{winnr} [, {tabnr}]])', 4015 }, 4016 getenv = { 4017 args = 1, 4018 base = 1, 4019 desc = [=[ 4020 Return the value of environment variable {name}. The {name} 4021 argument is a string, without a leading '$'. Example: >vim 4022 myHome = getenv('HOME') 4023 4024 <When the variable does not exist |v:null| is returned. That 4025 is different from a variable set to an empty string. 4026 See also |expr-env|. 4027 4028 ]=], 4029 name = 'getenv', 4030 params = { { 'name', 'string' } }, 4031 returns = 'string', 4032 signature = 'getenv({name})', 4033 }, 4034 getfontname = { 4035 args = { 0, 1 }, 4036 desc = [=[ 4037 Without an argument returns the name of the normal font being 4038 used. Like what is used for the Normal highlight group 4039 |hl-Normal|. 4040 With an argument a check is done whether String {name} is a 4041 valid font name. If not then an empty string is returned. 4042 Otherwise the actual font name is returned, or {name} if the 4043 GUI does not support obtaining the real name. 4044 Only works when the GUI is running, thus not in your vimrc or 4045 gvimrc file. Use the |GUIEnter| autocommand to use this 4046 function just after the GUI has started. 4047 ]=], 4048 name = 'getfontname', 4049 params = { { 'name', 'string' } }, 4050 returns = 'string', 4051 signature = 'getfontname([{name}])', 4052 }, 4053 getfperm = { 4054 args = 1, 4055 base = 1, 4056 desc = [=[ 4057 The result is a String, which is the read, write, and execute 4058 permissions of the given file {fname}. 4059 If {fname} does not exist or its directory cannot be read, an 4060 empty string is returned. 4061 The result is of the form "rwxrwxrwx", where each group of 4062 "rwx" flags represent, in turn, the permissions of the owner 4063 of the file, the group the file belongs to, and other users. 4064 If a user does not have a given permission the flag for this 4065 is replaced with the string "-". Examples: >vim 4066 echo getfperm("/etc/passwd") 4067 echo getfperm(expand("~/.config/nvim/init.vim")) 4068 <This will hopefully (from a security point of view) display 4069 the string "rw-r--r--" or even "rw-------". 4070 4071 For setting permissions use |setfperm()|. 4072 ]=], 4073 fast = true, 4074 name = 'getfperm', 4075 params = { { 'fname', 'string' } }, 4076 returns = 'string', 4077 signature = 'getfperm({fname})', 4078 }, 4079 getfsize = { 4080 args = 1, 4081 base = 1, 4082 desc = [=[ 4083 The result is a Number, which is the size in bytes of the 4084 given file {fname}. 4085 If {fname} is a directory, 0 is returned. 4086 If the file {fname} can't be found, -1 is returned. 4087 If the size of {fname} is too big to fit in a Number then -2 4088 is returned. 4089 4090 ]=], 4091 fast = true, 4092 name = 'getfsize', 4093 params = { { 'fname', 'string' } }, 4094 returns = 'integer', 4095 signature = 'getfsize({fname})', 4096 }, 4097 getftime = { 4098 args = 1, 4099 base = 1, 4100 desc = [=[ 4101 The result is a Number, which is the last modification time of 4102 the given file {fname}. The value is measured as seconds 4103 since 1st Jan 1970, and may be passed to |strftime()|. See also 4104 |localtime()| and |strftime()|. 4105 If the file {fname} can't be found -1 is returned. 4106 4107 ]=], 4108 fast = true, 4109 name = 'getftime', 4110 params = { { 'fname', 'string' } }, 4111 returns = 'integer', 4112 signature = 'getftime({fname})', 4113 }, 4114 getftype = { 4115 args = 1, 4116 base = 1, 4117 desc = [=[ 4118 The result is a String, which is a description of the kind of 4119 file of the given file {fname}. 4120 If {fname} does not exist an empty string is returned. 4121 Here is a table over different kinds of files and their 4122 results: 4123 Normal file "file" 4124 Directory "dir" 4125 Symbolic link "link" 4126 Block device "bdev" 4127 Character device "cdev" 4128 Socket "socket" 4129 FIFO "fifo" 4130 All other "other" 4131 Example: >vim 4132 getftype("/home") 4133 <Note that a type such as "link" will only be returned on 4134 systems that support it. On some systems only "dir" and 4135 "file" are returned. 4136 4137 ]=], 4138 fast = true, 4139 name = 'getftype', 4140 params = { { 'fname', 'string' } }, 4141 returns = "'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'", 4142 signature = 'getftype({fname})', 4143 }, 4144 getjumplist = { 4145 args = { 0, 2 }, 4146 base = 1, 4147 desc = [=[ 4148 Returns the |jumplist| for the specified window. 4149 4150 Without arguments use the current window. 4151 With {winnr} only use this window in the current tab page. 4152 {winnr} can also be a |window-ID|. 4153 With {winnr} and {tabnr} use the window in the specified tab 4154 page. If {winnr} or {tabnr} is invalid, an empty list is 4155 returned. 4156 4157 The returned list contains two entries: a list with the jump 4158 locations and the last used jump position number in the list. 4159 Each entry in the jump location list is a dictionary with 4160 the following entries: 4161 bufnr buffer number 4162 col column number 4163 coladd column offset for 'virtualedit' 4164 filename filename if available 4165 lnum line number 4166 4167 ]=], 4168 name = 'getjumplist', 4169 params = { { 'winnr', 'integer' }, { 'tabnr', 'integer' } }, 4170 signature = 'getjumplist([{winnr} [, {tabnr}]])', 4171 returns = 'vim.fn.getjumplist.ret', 4172 }, 4173 getline = { 4174 args = { 1, 2 }, 4175 base = 1, 4176 desc = [=[ 4177 Without {end} the result is a String, which is line {lnum} 4178 from the current buffer. Example: >vim 4179 getline(1) 4180 <When {lnum} is a String that doesn't start with a 4181 digit, |line()| is called to translate the String into a Number. 4182 To get the line under the cursor: >vim 4183 getline(".") 4184 <When {lnum} is a number smaller than 1 or bigger than the 4185 number of lines in the buffer, an empty string is returned. 4186 4187 When {end} is given the result is a |List| where each item is 4188 a line from the current buffer in the range {lnum} to {end}, 4189 including line {end}. 4190 {end} is used in the same way as {lnum}. 4191 Non-existing lines are silently omitted. 4192 When {end} is before {lnum} an empty |List| is returned. 4193 Example: >vim 4194 let start = line('.') 4195 let end = search("^$") - 1 4196 let lines = getline(start, end) 4197 4198 <To get lines from another buffer see |getbufline()| and 4199 |getbufoneline()| 4200 ]=], 4201 name = 'getline', 4202 params = { { 'lnum', 'integer|string' }, { 'end', 'nil|false' } }, 4203 signature = 'getline({lnum} [, {end}])', 4204 returns = 'string', 4205 }, 4206 getline__1 = { 4207 args = { 2 }, 4208 base = 1, 4209 name = 'getline', 4210 params = { { 'lnum', 'integer|string' }, { 'end', 'true|number|string|table' } }, 4211 returns = 'string|string[]', 4212 }, 4213 getloclist = { 4214 args = { 1, 2 }, 4215 desc = [=[ 4216 Returns a |List| with all the entries in the location list for 4217 window {nr}. {nr} can be the window number or the |window-ID|. 4218 When {nr} is zero the current window is used. 4219 4220 For a location list window, the displayed location list is 4221 returned. For an invalid window number {nr}, an empty list is 4222 returned. Otherwise, same as |getqflist()|. 4223 4224 If the optional {what} dictionary argument is supplied, then 4225 returns the items listed in {what} as a dictionary. Refer to 4226 |getqflist()| for the supported items in {what}. 4227 4228 In addition to the items supported by |getqflist()| in {what}, 4229 the following item is supported by |getloclist()|: 4230 4231 filewinid id of the window used to display files 4232 from the location list. This field is 4233 applicable only when called from a 4234 location list window. See 4235 |location-list-file-window| for more 4236 details. 4237 4238 Returns a |Dictionary| with default values if there is no 4239 location list for the window {nr}. 4240 Returns an empty Dictionary if window {nr} does not exist. 4241 4242 Examples (See also |getqflist-examples|): >vim 4243 echo getloclist(3, {'all': 0}) 4244 echo getloclist(5, {'filewinid': 0}) 4245 < 4246 ]=], 4247 name = 'getloclist', 4248 params = { { 'nr', 'integer' }, { 'what', 'table' } }, 4249 signature = 'getloclist({nr} [, {what}])', 4250 }, 4251 getmarklist = { 4252 args = { 0, 1 }, 4253 base = 1, 4254 desc = [=[ 4255 Without the {buf} argument returns a |List| with information 4256 about all the global marks. |mark| 4257 4258 If the optional {buf} argument is specified, returns the 4259 local marks defined in buffer {buf}. For the use of {buf}, 4260 see |bufname()|. If {buf} is invalid, an empty list is 4261 returned. 4262 4263 Each item in the returned List is a |Dict| with the following: 4264 mark name of the mark prefixed by "'" 4265 pos a |List| with the position of the mark: 4266 [bufnum, lnum, col, off] 4267 Refer to |getpos()| for more information. 4268 file file name 4269 4270 Refer to |getpos()| for getting information about a specific 4271 mark. 4272 4273 ]=], 4274 name = 'getmarklist', 4275 params = { { 'buf', 'integer?' } }, 4276 signature = 'getmarklist([{buf}])', 4277 returns = 'vim.fn.getmarklist.ret.item[]', 4278 }, 4279 getmatches = { 4280 args = { 0, 1 }, 4281 desc = [=[ 4282 Returns a |List| with all matches previously defined for the 4283 current window by |matchadd()| and the |:match| commands. 4284 |getmatches()| is useful in combination with |setmatches()|, 4285 as |setmatches()| can restore a list of matches saved by 4286 |getmatches()|. 4287 If {win} is specified, use the window with this number or 4288 window ID instead of the current window. If {win} is invalid, 4289 an empty list is returned. 4290 Example: >vim 4291 echo getmatches() 4292 < > 4293 [{"group": "MyGroup1", "pattern": "TODO", 4294 "priority": 10, "id": 1}, {"group": "MyGroup2", 4295 "pattern": "FIXME", "priority": 10, "id": 2}] 4296 < >vim 4297 let m = getmatches() 4298 call clearmatches() 4299 echo getmatches() 4300 < > 4301 [] 4302 < >vim 4303 call setmatches(m) 4304 echo getmatches() 4305 < > 4306 [{"group": "MyGroup1", "pattern": "TODO", 4307 "priority": 10, "id": 1}, {"group": "MyGroup2", 4308 "pattern": "FIXME", "priority": 10, "id": 2}] 4309 < >vim 4310 unlet m 4311 < 4312 ]=], 4313 name = 'getmatches', 4314 params = { { 'win', 'integer' } }, 4315 returns = 'vim.fn.getmatches.ret.item[]', 4316 signature = 'getmatches([{win}])', 4317 }, 4318 getmousepos = { 4319 desc = [=[ 4320 Returns a |Dictionary| with the last known position of the 4321 mouse. This can be used in a mapping for a mouse click. The 4322 items are: 4323 screenrow screen row 4324 screencol screen column 4325 winid Window ID of the click 4326 winrow row inside "winid" 4327 wincol column inside "winid" 4328 line text line inside "winid" 4329 column text column inside "winid" 4330 coladd offset (in screen columns) from the 4331 start of the clicked char 4332 All numbers are 1-based. 4333 4334 If not over a window, e.g. when in the command line, then only 4335 "screenrow" and "screencol" are valid, the others are zero. 4336 4337 When on the status line below a window or the vertical 4338 separator right of a window, the "line" and "column" values 4339 are zero. 4340 4341 When the position is after the text then "column" is the 4342 length of the text in bytes plus one. 4343 4344 If the mouse is over a focusable floating window then that 4345 window is used. 4346 4347 When using |getchar()| the Vim variables |v:mouse_lnum|, 4348 |v:mouse_col| and |v:mouse_winid| also provide these values. 4349 ]=], 4350 name = 'getmousepos', 4351 params = {}, 4352 signature = 'getmousepos()', 4353 returns = 'vim.fn.getmousepos.ret', 4354 }, 4355 getpid = { 4356 desc = [=[ 4357 Return a Number which is the process ID of the Vim process. 4358 This is a unique number, until Vim exits. 4359 ]=], 4360 fast = true, 4361 name = 'getpid', 4362 params = {}, 4363 returns = 'integer', 4364 signature = 'getpid()', 4365 }, 4366 getpos = { 4367 args = 1, 4368 base = 1, 4369 desc = [=[ 4370 Gets a position, where {expr} is one of: 4371 . Cursor position. 4372 $ Last line in the current buffer. 4373 'x Position of mark x (if the mark is not set, 0 is 4374 returned for all values). 4375 w0 First line visible in current window (one if the 4376 display isn't updated, e.g. in silent Ex mode). 4377 w$ Last line visible in current window (this is one 4378 less than "w0" if no lines are visible). 4379 v End of the current Visual selection (unlike |'<| 4380 |'>| which give the previous, not current, Visual 4381 selection), or the cursor position if not in Visual 4382 mode. 4383 4384 To get the current selected region: >vim 4385 let region = getregionpos(getpos('v'), getpos('.')) 4386 < 4387 Explanation: in Visual mode "v" and "." complement each 4388 other. While "." refers to the cursor position, "v" 4389 refers to where |v_o| would move the cursor. So you can 4390 use "v" and "." together to get the selected region. 4391 4392 Note that if a mark in another file is used, the line number 4393 applies to that buffer. 4394 4395 The result is a |List| with four numbers: 4396 [bufnum, lnum, col, off] 4397 "bufnum" is zero, unless a mark like '0 or 'A is used, then it 4398 is the buffer number of the mark. 4399 "lnum" and "col" are the position in the buffer. The first 4400 column is 1. 4401 The "off" number is zero, unless 'virtualedit' is used. Then 4402 it is the offset in screen columns from the start of the 4403 character. E.g., a position within a <Tab> or after the last 4404 character. 4405 4406 For getting the cursor position see |getcurpos()|. 4407 The column number in the returned List is the byte position 4408 within the line. To get the character position in the line, 4409 use |getcharpos()|. 4410 4411 The visual marks |'<| and |'>| refer to the beginning and end 4412 of the visual selection relative to the buffer. Note that 4413 this differs from |setpos()|, where they are relative to the 4414 cursor position. 4415 4416 Note that for '< and '> Visual mode matters: when it is "V" 4417 (visual line mode) the column of '< is zero and the column of 4418 '> is a large number equal to |v:maxcol|. 4419 A very large column number equal to |v:maxcol| can be returned, 4420 in which case it means "after the end of the line". 4421 If {expr} is invalid, returns a list with all zeros. 4422 4423 This can be used to save and restore the position of a mark: >vim 4424 let save_a_mark = getpos("'a") 4425 " ... 4426 call setpos("'a", save_a_mark) 4427 < 4428 Also see |getcharpos()|, |getcurpos()| and |setpos()|. 4429 4430 ]=], 4431 name = 'getpos', 4432 params = { { 'expr', 'string' } }, 4433 returns = '[integer, integer, integer, integer]', 4434 signature = 'getpos({expr})', 4435 }, 4436 getqflist = { 4437 args = { 0, 1 }, 4438 desc = [=[ 4439 Returns a |List| with all the current quickfix errors. Each 4440 list item is a dictionary with these entries: 4441 bufnr number of buffer that has the file name, use 4442 |bufname()| to get the name 4443 module module name 4444 lnum line number in the buffer (first line is 1) 4445 end_lnum 4446 end of line number if the item is multiline 4447 col column number (first column is 1) 4448 end_col end of column number if the item has range 4449 vcol |TRUE|: "col" is visual column 4450 |FALSE|: "col" is byte index 4451 nr error number 4452 pattern search pattern used to locate the error 4453 text description of the error 4454 type type of the error, 'E', '1', etc. 4455 valid |TRUE|: recognized error message 4456 user_data 4457 custom data associated with the item, can be 4458 any type. 4459 4460 When there is no error list or it's empty, an empty list is 4461 returned. Quickfix list entries with a non-existing buffer 4462 number are returned with "bufnr" set to zero (Note: some 4463 functions accept buffer number zero for the alternate buffer, 4464 you may need to explicitly check for zero). 4465 4466 Useful application: Find pattern matches in multiple files and 4467 do something with them: >vim 4468 vimgrep /theword/jg *.c 4469 for d in getqflist() 4470 echo bufname(d.bufnr) ':' d.lnum '=' d.text 4471 endfor 4472 < 4473 If the optional {what} dictionary argument is supplied, then 4474 returns only the items listed in {what} as a dictionary. The 4475 following string items are supported in {what}: 4476 changedtick get the total number of changes made 4477 to the list |quickfix-changedtick| 4478 context get the |quickfix-context| 4479 efm errorformat to use when parsing "lines". If 4480 not present, then the 'errorformat' option 4481 value is used. 4482 id get information for the quickfix list with 4483 |quickfix-ID|; zero means the id for the 4484 current list or the list specified by "nr" 4485 idx get information for the quickfix entry at this 4486 index in the list specified by "id" or "nr". 4487 If set to zero, then uses the current entry. 4488 See |quickfix-index| 4489 items quickfix list entries 4490 lines parse a list of lines using 'efm' and return 4491 the resulting entries. Only a |List| type is 4492 accepted. The current quickfix list is not 4493 modified. See |quickfix-parse|. 4494 nr get information for this quickfix list; zero 4495 means the current quickfix list and "$" means 4496 the last quickfix list 4497 qfbufnr number of the buffer displayed in the quickfix 4498 window. Returns 0 if the quickfix buffer is 4499 not present. See |quickfix-buffer|. 4500 size number of entries in the quickfix list 4501 title get the list title |quickfix-title| 4502 winid get the quickfix |window-ID| 4503 all all of the above quickfix properties 4504 Non-string items in {what} are ignored. To get the value of a 4505 particular item, set it to zero. 4506 If "nr" is not present then the current quickfix list is used. 4507 If both "nr" and a non-zero "id" are specified, then the list 4508 specified by "id" is used. 4509 To get the number of lists in the quickfix stack, set "nr" to 4510 "$" in {what}. The "nr" value in the returned dictionary 4511 contains the quickfix stack size. 4512 When "lines" is specified, all the other items except "efm" 4513 are ignored. The returned dictionary contains the entry 4514 "items" with the list of entries. 4515 4516 The returned dictionary contains the following entries: 4517 changedtick total number of changes made to the 4518 list |quickfix-changedtick| 4519 context quickfix list context. See |quickfix-context| 4520 If not present, set to "". 4521 id quickfix list ID |quickfix-ID|. If not 4522 present, set to 0. 4523 idx index of the quickfix entry in the list. If 4524 not present, set to 0. 4525 items quickfix list entries. If not present, set to 4526 an empty list. 4527 nr quickfix list number. If not present, set to 4528 0 4529 qfbufnr number of the buffer displayed in the quickfix 4530 window. If not present, set to 0. 4531 size number of entries in the quickfix list. If 4532 not present, set to 0. 4533 title quickfix list title text. If not present, set 4534 to "". 4535 winid quickfix |window-ID|. If not present, set to 0 4536 4537 Examples (See also |getqflist-examples|): >vim 4538 echo getqflist({'all': 1}) 4539 echo getqflist({'nr': 2, 'title': 1}) 4540 echo getqflist({'lines' : ["F1:10:L10"]}) 4541 < 4542 ]=], 4543 name = 'getqflist', 4544 params = { { 'what', 'table' } }, 4545 signature = 'getqflist([{what}])', 4546 }, 4547 getreg = { 4548 args = { 0, 3 }, 4549 base = 1, 4550 desc = [=[ 4551 The result is a String, which is the contents of register 4552 {regname}. Example: >vim 4553 let cliptext = getreg('*') 4554 <When register {regname} was not set the result is an empty 4555 string. 4556 The {regname} argument must be a string. 4557 4558 getreg('=') returns the last evaluated value of the expression 4559 register. (For use in maps.) 4560 getreg('=', 1) returns the expression itself, so that it can 4561 be restored with |setreg()|. For other registers the extra 4562 argument is ignored, thus you can always give it. 4563 4564 If {list} is present and |TRUE|, the result type is changed 4565 to |List|. Each list item is one text line. Use it if you care 4566 about zero bytes possibly present inside register: without 4567 third argument both NLs and zero bytes are represented as NLs 4568 (see |NL-used-for-Nul|). 4569 When the register was not set an empty list is returned. 4570 4571 If {regname} is not specified, |v:register| is used. 4572 4573 ]=], 4574 name = 'getreg', 4575 params = { { 'regname', 'string' }, { 'expr', 'any' }, { 'list', 'nil|false' } }, 4576 signature = 'getreg([{regname} [, 1 [, {list}]]])', 4577 returns = 'string', 4578 }, 4579 getreg__1 = { 4580 args = { 3 }, 4581 base = 1, 4582 name = 'getreg', 4583 params = { { 'regname', 'string' }, { 'expr', 'any' }, { 'list', 'true|number|string|table' } }, 4584 returns = 'string[]', 4585 }, 4586 getreginfo = { 4587 args = { 0, 1 }, 4588 base = 1, 4589 desc = [=[ 4590 Returns detailed information about register {regname} as a 4591 Dictionary with the following entries: 4592 regcontents List of lines contained in register 4593 {regname}, like 4594 getreg({regname}, 1, 1). 4595 regtype the type of register {regname}, as in 4596 |getregtype()|. 4597 isunnamed Boolean flag, v:true if this register 4598 is currently pointed to by the unnamed 4599 register. 4600 points_to for the unnamed register, gives the 4601 single letter name of the register 4602 currently pointed to (see |quotequote|). 4603 For example, after deleting a line 4604 with `dd`, this field will be "1", 4605 which is the register that got the 4606 deleted text. 4607 4608 The {regname} argument is a string. If {regname} is invalid 4609 or not set, an empty Dictionary will be returned. 4610 If {regname} is not specified, |v:register| is used. 4611 The returned Dictionary can be passed to |setreg()|. 4612 4613 ]=], 4614 name = 'getreginfo', 4615 params = { { 'regname', 'string' } }, 4616 returns = 'table', 4617 signature = 'getreginfo([{regname}])', 4618 }, 4619 getregion = { 4620 args = { 2, 3 }, 4621 base = 1, 4622 desc = [=[ 4623 Returns the list of strings from {pos1} to {pos2} from a 4624 buffer. 4625 4626 {pos1} and {pos2} must both be |List|s with four numbers. 4627 See |getpos()| for the format of the list. It's possible 4628 to specify positions from a different buffer, but please 4629 note the limitations at |getregion-notes|. 4630 4631 The optional argument {opts} is a Dict and supports the 4632 following items: 4633 4634 type Specify the region's selection type. 4635 See |getregtype()| for possible values, 4636 except that the width can be omitted 4637 and an empty string cannot be used. 4638 (default: "v") 4639 4640 exclusive If |TRUE|, use exclusive selection 4641 for the end position. 4642 (default: follow 'selection') 4643 4644 You can get the last selection type by |visualmode()|. 4645 If Visual mode is active, use |mode()| to get the Visual mode 4646 (e.g., in a |:vmap|). 4647 This function is useful to get text starting and ending in 4648 different columns, such as a |charwise-visual| selection. 4649 4650 *getregion-notes* 4651 Note that: 4652 - Order of {pos1} and {pos2} doesn't matter, it will always 4653 return content from the upper left position to the lower 4654 right position. 4655 - If 'virtualedit' is enabled and the region is past the end 4656 of the lines, resulting lines are padded with spaces. 4657 - If the region is blockwise and it starts or ends in the 4658 middle of a multi-cell character, it is not included but 4659 its selected part is substituted with spaces. 4660 - If {pos1} and {pos2} are not in the same buffer, an empty 4661 list is returned. 4662 - {pos1} and {pos2} must belong to a |bufloaded()| buffer. 4663 - It is evaluated in current window context, which makes a 4664 difference if the buffer is displayed in a window with 4665 different 'virtualedit' or 'list' values. 4666 - When specifying an exclusive selection and {pos1} and {pos2} 4667 are equal, the returned list contains a single character as 4668 if selection is inclusive, to match the behavior of an empty 4669 exclusive selection in Visual mode. 4670 4671 Examples: >vim 4672 xnoremap <CR> 4673 \ <Cmd>echom getregion( 4674 \ getpos('v'), getpos('.'), #{ type: mode() })<CR> 4675 < 4676 ]=], 4677 name = 'getregion', 4678 params = { 4679 { 'pos1', '[integer, integer, integer, integer]' }, 4680 { 'pos2', '[integer, integer, integer, integer]' }, 4681 { 'opts', '{type?:string, exclusive?:boolean}' }, 4682 }, 4683 returns = 'string[]', 4684 signature = 'getregion({pos1}, {pos2} [, {opts}])', 4685 }, 4686 getregionpos = { 4687 args = { 2, 3 }, 4688 base = 1, 4689 desc = [=[ 4690 Same as |getregion()|, but returns a list of positions 4691 describing the buffer text segments bound by {pos1} and 4692 {pos2}. 4693 The segments are a pair of positions for every line: > 4694 [[{start_pos}, {end_pos}], ...] 4695 < 4696 The position is a |List| with four numbers: 4697 [bufnum, lnum, col, off] 4698 "bufnum" is the buffer number. 4699 "lnum" and "col" are the position in the buffer. The first 4700 column is 1. 4701 If the "off" number of a starting position is non-zero, it is 4702 the offset in screen columns from the start of the character. 4703 E.g., a position within a <Tab> or after the last character. 4704 If the "off" number of an ending position is non-zero, it is 4705 the offset of the character's first cell not included in the 4706 selection, otherwise all its cells are included. 4707 4708 To get the current visual selection: >vim 4709 let region = getregionpos(getpos('v'), getpos('.')) 4710 < 4711 The {opts} Dict supports the following items: 4712 4713 type See |getregion()|. 4714 4715 exclusive See |getregion()|. 4716 4717 eol If |TRUE|, indicate positions beyond 4718 the end of a line with "col" values 4719 one more than the length of the line. 4720 If |FALSE|, positions are limited 4721 within their lines, and if a line is 4722 empty or the selection is entirely 4723 beyond the end of a line, a "col" 4724 value of 0 is used for both positions. 4725 (default: |FALSE|) 4726 ]=], 4727 name = 'getregionpos', 4728 params = { 4729 { 'pos1', '[integer, integer, integer, integer]' }, 4730 { 'pos2', '[integer, integer, integer, integer]' }, 4731 { 'opts', '{type?:string, exclusive?:boolean, eol?:boolean}' }, 4732 }, 4733 returns = '[ [integer, integer, integer, integer], [integer, integer, integer, integer] ][]', 4734 signature = 'getregionpos({pos1}, {pos2} [, {opts}])', 4735 }, 4736 getregtype = { 4737 args = { 0, 1 }, 4738 base = 1, 4739 desc = [=[ 4740 The result is a String, which is type of register {regname}. 4741 The value will be one of: 4742 "v" for |charwise| text 4743 "V" for |linewise| text 4744 "<CTRL-V>{width}" for |blockwise-visual| text 4745 "" for an empty or unknown register 4746 <CTRL-V> is one character with value 0x16. 4747 The {regname} argument is a string. If {regname} is not 4748 specified, |v:register| is used. 4749 4750 ]=], 4751 name = 'getregtype', 4752 params = { { 'regname', 'string' } }, 4753 returns = 'string', 4754 signature = 'getregtype([{regname}])', 4755 }, 4756 getscriptinfo = { 4757 args = { 0, 1 }, 4758 desc = [=[ 4759 Returns a |List| with information about all the sourced Vim 4760 scripts in the order they were sourced, like what 4761 `:scriptnames` shows. 4762 4763 The optional Dict argument {opts} supports the following 4764 optional items: 4765 name Script name match pattern. If specified, 4766 and "sid" is not specified, information about 4767 scripts with a name that match the pattern 4768 "name" are returned. 4769 sid Script ID |<SID>|. If specified, only 4770 information about the script with ID "sid" is 4771 returned and "name" is ignored. 4772 4773 Each item in the returned List is a |Dict| with the following 4774 items: 4775 autoload Always set to FALSE. 4776 functions List of script-local function names defined in 4777 the script. Present only when a particular 4778 script is specified using the "sid" item in 4779 {opts}. 4780 name Vim script file name. 4781 sid Script ID |<SID>|. 4782 variables A dictionary with the script-local variables. 4783 Present only when a particular script is 4784 specified using the "sid" item in {opts}. 4785 Note that this is a copy, the value of 4786 script-local variables cannot be changed using 4787 this dictionary. 4788 version Vim script version, always 1 4789 4790 Examples: >vim 4791 echo getscriptinfo({'name': 'myscript'}) 4792 echo getscriptinfo({'sid': 15})[0].variables 4793 < 4794 ]=], 4795 name = 'getscriptinfo', 4796 params = { { 'opts', 'table' } }, 4797 returns = 'vim.fn.getscriptinfo.ret[]', 4798 signature = 'getscriptinfo([{opts}])', 4799 }, 4800 getstacktrace = { 4801 args = 0, 4802 desc = [=[ 4803 Returns the current stack trace of Vim scripts. 4804 Stack trace is a |List|, of which each item is a |Dictionary| 4805 with the following items: 4806 funcref The funcref if the stack is at a function, 4807 otherwise this item is omitted. 4808 event The string of the event description if the 4809 stack is at an autocmd event, otherwise this 4810 item is omitted. 4811 lnum The line number in the script on the stack. 4812 filepath The file path of the script on the stack. 4813 ]=], 4814 name = 'getstacktrace', 4815 params = {}, 4816 returns = 'table[]', 4817 signature = 'getstacktrace()', 4818 }, 4819 gettabinfo = { 4820 args = { 0, 1 }, 4821 base = 1, 4822 desc = [=[ 4823 If {tabnr} is not specified, then information about all the 4824 tab pages is returned as a |List|. Each List item is a 4825 |Dictionary|. Otherwise, {tabnr} specifies the tab page 4826 number and information about that one is returned. If the tab 4827 page does not exist an empty List is returned. 4828 4829 Each List item is a |Dictionary| with the following entries: 4830 tabnr tab page number. 4831 variables a reference to the dictionary with 4832 tabpage-local variables 4833 windows List of |window-ID|s in the tab page. 4834 4835 ]=], 4836 name = 'gettabinfo', 4837 params = { { 'tabnr', 'integer' } }, 4838 signature = 'gettabinfo([{tabnr}])', 4839 }, 4840 gettabvar = { 4841 args = { 2, 3 }, 4842 base = 1, 4843 desc = [=[ 4844 Get the value of a tab-local variable {varname} in tab page 4845 {tabnr}. |t:var| 4846 Tabs are numbered starting with one. 4847 The {varname} argument is a string. When {varname} is empty a 4848 dictionary with all tab-local variables is returned. 4849 Note that the name without "t:" must be used. 4850 When the tab or variable doesn't exist {def} or an empty 4851 string is returned, there is no error message. 4852 4853 ]=], 4854 name = 'gettabvar', 4855 params = { { 'tabnr', 'integer' }, { 'varname', 'string' }, { 'def', 'any' } }, 4856 signature = 'gettabvar({tabnr}, {varname} [, {def}])', 4857 }, 4858 gettabwinvar = { 4859 args = { 3, 4 }, 4860 base = 1, 4861 desc = [=[ 4862 Get the value of window-local variable {varname} in window 4863 {winnr} in tab page {tabnr}. 4864 The {varname} argument is a string. When {varname} is empty a 4865 dictionary with all window-local variables is returned. 4866 When {varname} is equal to "&" get the values of all 4867 window-local options in a |Dictionary|. 4868 Otherwise, when {varname} starts with "&" get the value of a 4869 window-local option. 4870 Note that {varname} must be the name without "w:". 4871 Tabs are numbered starting with one. For the current tabpage 4872 use |getwinvar()|. 4873 {winnr} can be the window number or the |window-ID|. 4874 When {winnr} is zero the current window is used. 4875 This also works for a global option, buffer-local option and 4876 window-local option, but it doesn't work for a global variable 4877 or buffer-local variable. 4878 When the tab, window or variable doesn't exist {def} or an 4879 empty string is returned, there is no error message. 4880 Examples: >vim 4881 let list_is_on = gettabwinvar(1, 2, '&list') 4882 echo "myvar = " .. gettabwinvar(3, 1, 'myvar') 4883 < 4884 To obtain all window-local variables use: >vim 4885 gettabwinvar({tabnr}, {winnr}, '&') 4886 < 4887 ]=], 4888 name = 'gettabwinvar', 4889 params = { 4890 { 'tabnr', 'integer' }, 4891 { 'winnr', 'integer' }, 4892 { 'varname', 'string' }, 4893 { 'def', 'any' }, 4894 }, 4895 signature = 'gettabwinvar({tabnr}, {winnr}, {varname} [, {def}])', 4896 }, 4897 gettagstack = { 4898 args = { 0, 1 }, 4899 base = 1, 4900 desc = [=[ 4901 The result is a Dict, which is the tag stack of window {winnr}. 4902 {winnr} can be the window number or the |window-ID|. 4903 When {winnr} is not specified, the current window is used. 4904 When window {winnr} doesn't exist, an empty Dict is returned. 4905 4906 The returned dictionary contains the following entries: 4907 curidx Current index in the stack. When at 4908 top of the stack, set to (length + 1). 4909 Index of bottom of the stack is 1. 4910 items List of items in the stack. Each item 4911 is a dictionary containing the 4912 entries described below. 4913 length Number of entries in the stack. 4914 4915 Each item in the stack is a dictionary with the following 4916 entries: 4917 bufnr buffer number of the current jump 4918 from cursor position before the tag jump. 4919 See |getpos()| for the format of the 4920 returned list. 4921 matchnr current matching tag number. Used 4922 when multiple matching tags are found 4923 for a name. 4924 tagname name of the tag 4925 4926 See |tagstack| for more information about the tag stack. 4927 4928 ]=], 4929 name = 'gettagstack', 4930 params = { { 'winnr', 'integer' } }, 4931 signature = 'gettagstack([{winnr}])', 4932 }, 4933 gettext = { 4934 args = 1, 4935 base = 1, 4936 desc = [=[ 4937 Translate String {text} if possible. 4938 This is mainly for use in the distributed Vim scripts. When 4939 generating message translations the {text} is extracted by 4940 xgettext, the translator can add the translated message in the 4941 .po file and Vim will lookup the translation when gettext() is 4942 called. 4943 For {text} double quoted strings are preferred, because 4944 xgettext does not understand escaping in single quoted 4945 strings. 4946 ]=], 4947 name = 'gettext', 4948 params = { { 'text', 'string' } }, 4949 returns = 'string', 4950 signature = 'gettext({text})', 4951 }, 4952 getwininfo = { 4953 args = { 0, 1 }, 4954 base = 1, 4955 desc = [=[ 4956 Returns information about windows as a |List| with Dictionaries. 4957 4958 If {winid} is given Information about the window with that ID 4959 is returned, as a |List| with one item. If the window does not 4960 exist the result is an empty list. 4961 4962 Without {winid} information about all the windows in all the 4963 tab pages is returned. 4964 4965 Each List item is a |Dictionary| with the following entries: 4966 botline last complete displayed buffer line 4967 bufnr number of buffer in the window 4968 height window height (excluding winbar) 4969 leftcol first column displayed; only used when 4970 'wrap' is off 4971 loclist 1 if showing a location list 4972 quickfix 1 if quickfix or location list window 4973 status_height status lines height (0 or 1) 4974 tabnr tab page number 4975 terminal 1 if a terminal window 4976 textoff number of columns occupied by any 4977 'foldcolumn', 'signcolumn' and line 4978 number in front of the text 4979 topline first displayed buffer line 4980 variables a reference to the dictionary with 4981 window-local variables 4982 width window width 4983 winbar 1 if the window has a toolbar, 0 4984 otherwise 4985 wincol leftmost screen column of the window; 4986 "col" from |win_screenpos()| 4987 winid |window-ID| 4988 winnr window number 4989 winrow topmost screen line of the window; 4990 "row" from |win_screenpos()| 4991 4992 ]=], 4993 name = 'getwininfo', 4994 params = { { 'winid', 'integer' } }, 4995 signature = 'getwininfo([{winid}])', 4996 returns = 'vim.fn.getwininfo.ret.item[]', 4997 }, 4998 getwinpos = { 4999 args = { 0, 1 }, 5000 base = 1, 5001 desc = [=[ 5002 The result is a |List| with two numbers, the result of 5003 |getwinposx()| and |getwinposy()| combined: 5004 [x-pos, y-pos] 5005 {timeout} can be used to specify how long to wait in msec for 5006 a response from the terminal. When omitted 100 msec is used. 5007 5008 Use a longer time for a remote terminal. 5009 When using a value less than 10 and no response is received 5010 within that time, a previously reported position is returned, 5011 if available. This can be used to poll for the position and 5012 do some work in the meantime: >vim 5013 while 1 5014 let res = getwinpos(1) 5015 if res[0] >= 0 5016 break 5017 endif 5018 " Do some work here 5019 endwhile 5020 < 5021 ]=], 5022 name = 'getwinpos', 5023 params = { { 'timeout', 'integer' } }, 5024 signature = 'getwinpos([{timeout}])', 5025 }, 5026 getwinposx = { 5027 desc = [=[ 5028 The result is a Number, which is the X coordinate in pixels of 5029 the left hand side of the GUI Vim window. The result will be 5030 -1 if the information is not available. 5031 The value can be used with `:winpos`. 5032 ]=], 5033 name = 'getwinposx', 5034 params = {}, 5035 returns = 'integer', 5036 signature = 'getwinposx()', 5037 }, 5038 getwinposy = { 5039 desc = [=[ 5040 The result is a Number, which is the Y coordinate in pixels of 5041 the top of the GUI Vim window. The result will be -1 if the 5042 information is not available. 5043 The value can be used with `:winpos`. 5044 ]=], 5045 name = 'getwinposy', 5046 params = {}, 5047 returns = 'integer', 5048 signature = 'getwinposy()', 5049 }, 5050 getwinvar = { 5051 args = { 2, 3 }, 5052 base = 1, 5053 desc = [=[ 5054 Like |gettabwinvar()| for the current tabpage. 5055 Examples: >vim 5056 let list_is_on = getwinvar(2, '&list') 5057 echo "myvar = " .. getwinvar(1, 'myvar') 5058 < 5059 ]=], 5060 name = 'getwinvar', 5061 params = { { 'winnr', 'integer' }, { 'varname', 'string' }, { 'def', 'any' } }, 5062 signature = 'getwinvar({winnr}, {varname} [, {def}])', 5063 }, 5064 glob = { 5065 args = { 1, 4 }, 5066 base = 1, 5067 desc = [=[ 5068 Expand the file wildcards in {expr}. See |wildcards| for the 5069 use of special characters. 5070 5071 Unless the optional {nosuf} argument is given and is |TRUE|, 5072 the 'suffixes' and 'wildignore' options apply: Names matching 5073 one of the patterns in 'wildignore' will be skipped and 5074 'suffixes' affect the ordering of matches. 5075 'wildignorecase' always applies. 5076 5077 When {list} is present and it is |TRUE| the result is a |List| 5078 with all matching files. The advantage of using a List is, 5079 you also get filenames containing newlines correctly. 5080 Otherwise the result is a String and when there are several 5081 matches, they are separated by <NL> characters. 5082 5083 If the expansion fails, the result is an empty String or List. 5084 5085 You can also use |readdir()| if you need to do complicated 5086 things, such as limiting the number of matches. 5087 5088 A name for a non-existing file is not included. A symbolic 5089 link is only included if it points to an existing file. 5090 However, when the {alllinks} argument is present and it is 5091 |TRUE| then all symbolic links are included. 5092 5093 For most systems backticks can be used to get files names from 5094 any external command. Example: >vim 5095 let tagfiles = glob("`find . -name tags -print`") 5096 let &tags = substitute(tagfiles, "\n", ",", "g") 5097 <The result of the program inside the backticks should be one 5098 item per line. Spaces inside an item are allowed. 5099 5100 See |expand()| for expanding special Vim variables. See 5101 |system()| for getting the raw output of an external command. 5102 5103 ]=], 5104 name = 'glob', 5105 params = { 5106 { 'expr', 'string' }, 5107 { 'nosuf', 'boolean' }, 5108 { 'list', 'boolean' }, 5109 { 'alllinks', 'boolean' }, 5110 }, 5111 signature = 'glob({expr} [, {nosuf} [, {list} [, {alllinks}]]])', 5112 }, 5113 glob2regpat = { 5114 args = 1, 5115 base = 1, 5116 desc = [=[ 5117 Convert a file pattern, as used by |glob()|, into a search 5118 pattern. The result can be used to match with a string that 5119 is a file name. E.g. >vim 5120 if filename =~ glob2regpat('Make*.mak') 5121 " ... 5122 endif 5123 <This is equivalent to: >vim 5124 if filename =~ '^Make.*\.mak$' 5125 " ... 5126 endif 5127 <When {string} is an empty string the result is "^$", match an 5128 empty string. 5129 Note that the result depends on the system. On MS-Windows 5130 a backslash usually means a path separator. 5131 5132 ]=], 5133 name = 'glob2regpat', 5134 params = { { 'string', 'string' } }, 5135 returns = 'string', 5136 signature = 'glob2regpat({string})', 5137 }, 5138 globpath = { 5139 args = { 2, 5 }, 5140 base = 2, 5141 desc = [=[ 5142 Perform |glob()| for String {expr} on all directories in {path} 5143 and concatenate the results. Example: >vim 5144 echo globpath(&rtp, "syntax/c.vim") 5145 < 5146 {path} is a comma-separated list of directory names. Each 5147 directory name is prepended to {expr} and expanded like with 5148 |glob()|. A path separator is inserted when needed. 5149 To add a comma inside a directory name escape it with a 5150 backslash. Note that on MS-Windows a directory may have a 5151 trailing backslash, remove it if you put a comma after it. 5152 If the expansion fails for one of the directories, there is no 5153 error message. 5154 5155 Unless the optional {nosuf} argument is given and is |TRUE|, 5156 the 'suffixes' and 'wildignore' options apply: Names matching 5157 one of the patterns in 'wildignore' will be skipped and 5158 'suffixes' affect the ordering of matches. 5159 5160 When {list} is present and it is |TRUE| the result is a |List| 5161 with all matching files. The advantage of using a List is, 5162 you also get filenames containing newlines correctly. 5163 Otherwise the result is a String and when there are several 5164 matches, they are separated by <NL> characters. Example: >vim 5165 echo globpath(&rtp, "syntax/c.vim", 0, 1) 5166 < 5167 {allinks} is used as with |glob()|. 5168 5169 The "**" item can be used to search in a directory tree. 5170 For example, to find all "README.txt" files in the directories 5171 in 'runtimepath' and below: >vim 5172 echo globpath(&rtp, "**/README.txt") 5173 <Upwards search and limiting the depth of "**" is not 5174 supported, thus using 'path' will not always work properly. 5175 5176 ]=], 5177 name = 'globpath', 5178 params = { 5179 { 'path', 'string' }, 5180 { 'expr', 'string' }, 5181 { 'nosuf', 'boolean' }, 5182 { 'list', 'boolean' }, 5183 { 'allinks', 'boolean' }, 5184 }, 5185 signature = 'globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])', 5186 }, 5187 has = { 5188 args = 1, 5189 desc = [=[ 5190 Returns 1 if {feature} is supported, 0 otherwise. The 5191 {feature} argument is a feature name like "nvim-0.2.1" or 5192 "win32", see below. See also |exists()|. 5193 5194 To get the system name use |vim.uv|.os_uname() in Lua: >lua 5195 print(vim.uv.os_uname().sysname) 5196 5197 <If the code has a syntax error then Vimscript may skip the 5198 rest of the line. Put |:if| and |:endif| on separate lines to 5199 avoid the syntax error: >vim 5200 if has('feature') 5201 let x = this_breaks_without_the_feature() 5202 endif 5203 < 5204 Vim's compile-time feature-names (prefixed with "+") are not 5205 recognized because Nvim is always compiled with all possible 5206 features. |feature-compile| 5207 5208 Feature names can be: 5209 1. Nvim version. For example the "nvim-0.2.1" feature means 5210 that Nvim is version 0.2.1 or later: >vim 5211 if has("nvim-0.2.1") 5212 " ... 5213 endif 5214 5215 <2. Runtime condition or other pseudo-feature. For example the 5216 "win32" feature checks if the current system is Windows: >vim 5217 if has("win32") 5218 " ... 5219 endif 5220 < *feature-list* 5221 List of supported pseudo-feature names: 5222 acl |ACL| support. 5223 bsd BSD system (not macOS, use "mac" for that). 5224 clipboard |clipboard| provider is available. 5225 fname_case Case in file names matters (for Darwin and MS-Windows 5226 this is not present). 5227 gui_running Nvim has a GUI. 5228 hurd GNU/Hurd system. 5229 iconv Can use |iconv()| for conversion. 5230 linux Linux system. 5231 mac MacOS system. 5232 nvim This is Nvim. 5233 python3 Legacy Vim |python3| interface. |has-python| 5234 pythonx Legacy Vim |python_x| interface. |has-pythonx| 5235 sun SunOS system. 5236 ttyin input is a terminal (tty). 5237 ttyout output is a terminal (tty). 5238 unix Unix system. 5239 *vim_starting* True during |startup|. 5240 win32 Windows system (32 or 64 bit). 5241 win64 Windows system (64 bit). 5242 wsl WSL (Windows Subsystem for Linux) system. 5243 5244 *has-patch* 5245 3. Vim patch. For example the "patch123" feature means that 5246 Vim patch 123 at the current |v:version| was included: >vim 5247 if v:version > 602 || v:version == 602 && has("patch148") 5248 " ... 5249 endif 5250 5251 <4. Vim version. For example the "patch-7.4.237" feature means 5252 that Nvim is Vim-compatible to version 7.4.237 or later. >vim 5253 if has("patch-7.4.237") 5254 " ... 5255 endif 5256 < 5257 ]=], 5258 fast = true, 5259 name = 'has', 5260 params = { { 'feature', 'string' } }, 5261 returns = '0|1', 5262 signature = 'has({feature})', 5263 }, 5264 has_key = { 5265 args = 2, 5266 base = 1, 5267 desc = [=[ 5268 The result is a Number, which is TRUE if |Dictionary| {dict} 5269 has an entry with key {key}. FALSE otherwise. The {key} 5270 argument is a string. 5271 5272 ]=], 5273 name = 'has_key', 5274 params = { { 'dict', 'table' }, { 'key', 'string' } }, 5275 returns = '0|1', 5276 signature = 'has_key({dict}, {key})', 5277 }, 5278 haslocaldir = { 5279 args = { 0, 2 }, 5280 base = 1, 5281 desc = [=[ 5282 The result is a Number, which is 1 when the window has set a 5283 local path via |:lcd| or when {winnr} is -1 and the tabpage 5284 has set a local path via |:tcd|, otherwise 0. 5285 5286 Tabs and windows are identified by their respective numbers, 5287 0 means current tab or window. Missing argument implies 0. 5288 Thus the following are equivalent: >vim 5289 echo haslocaldir() 5290 echo haslocaldir(0) 5291 echo haslocaldir(0, 0) 5292 <With {winnr} use that window in the current tabpage. 5293 With {winnr} and {tabnr} use the window in that tabpage. 5294 {winnr} can be the window number or the |window-ID|. 5295 If {winnr} is -1 it is ignored, only the tab is resolved. 5296 Throw error if the arguments are invalid. |E5000| |E5001| |E5002| 5297 5298 ]=], 5299 name = 'haslocaldir', 5300 params = { { 'winnr', 'integer' }, { 'tabnr', 'integer' } }, 5301 returns = '0|1', 5302 signature = 'haslocaldir([{winnr} [, {tabnr}]])', 5303 }, 5304 hasmapto = { 5305 args = { 1, 3 }, 5306 base = 1, 5307 desc = [=[ 5308 The result is a Number, which is TRUE if there is a mapping 5309 that contains {what} in somewhere in the rhs (what it is 5310 mapped to) and this mapping exists in one of the modes 5311 indicated by {mode}. 5312 The arguments {what} and {mode} are strings. 5313 When {abbr} is there and it is |TRUE| use abbreviations 5314 instead of mappings. Don't forget to specify Insert and/or 5315 Command-line mode. 5316 Both the global mappings and the mappings local to the current 5317 buffer are checked for a match. 5318 If no matching mapping is found FALSE is returned. 5319 The following characters are recognized in {mode}: 5320 n Normal mode 5321 v Visual and Select mode 5322 x Visual mode 5323 s Select mode 5324 o Operator-pending mode 5325 i Insert mode 5326 l Language-Argument ("r", "f", "t", etc.) 5327 c Command-line mode 5328 When {mode} is omitted, "nvo" is used. 5329 5330 This function is useful to check if a mapping already exists 5331 to a function in a Vim script. Example: >vim 5332 if !hasmapto('\ABCdoit') 5333 map <Leader>d \ABCdoit 5334 endif 5335 <This installs the mapping to "\ABCdoit" only if there isn't 5336 already a mapping to "\ABCdoit". 5337 5338 ]=], 5339 name = 'hasmapto', 5340 params = { { 'what', 'any' }, { 'mode', 'string' }, { 'abbr', 'boolean' } }, 5341 returns = '0|1', 5342 signature = 'hasmapto({what} [, {mode} [, {abbr}]])', 5343 }, 5344 highlightID = { 5345 args = 1, 5346 base = 1, 5347 deprecated = true, 5348 desc = [=[ 5349 Obsolete name for |hlID()|. 5350 ]=], 5351 func = 'f_hlID', 5352 params = { { 'name', 'string' } }, 5353 signature = 'highlightID({name})', 5354 }, 5355 highlight_exists = { 5356 args = 1, 5357 base = 1, 5358 deprecated = true, 5359 desc = [=[ 5360 Obsolete name for |hlexists()|. 5361 ]=], 5362 func = 'f_hlexists', 5363 params = { { 'name', 'string' } }, 5364 signature = 'highlight_exists({name})', 5365 }, 5366 histadd = { 5367 args = 2, 5368 base = 2, 5369 desc = [=[ 5370 Add the String {item} to the history {history} which can be 5371 one of: *hist-names* 5372 "cmd" or ":" command line history 5373 "search" or "/" search pattern history 5374 "expr" or "=" typed expression history 5375 "input" or "@" input line history 5376 "debug" or ">" debug command history 5377 empty the current or last used history 5378 The {history} string does not need to be the whole name, one 5379 character is sufficient. 5380 If {item} does already exist in the history, it will be 5381 shifted to become the newest entry. 5382 The result is a Number: TRUE if the operation was successful, 5383 otherwise FALSE is returned. 5384 5385 Example: >vim 5386 call histadd("input", strftime("%Y %b %d")) 5387 let date=input("Enter date: ") 5388 <This function is not available in the |sandbox|. 5389 5390 ]=], 5391 name = 'histadd', 5392 params = { { 'history', 'string' }, { 'item', 'any' } }, 5393 returns = '0|1', 5394 signature = 'histadd({history}, {item})', 5395 }, 5396 histdel = { 5397 args = { 1, 2 }, 5398 base = 1, 5399 desc = [=[ 5400 Clear {history}, i.e. delete all its entries. See |hist-names| 5401 for the possible values of {history}. 5402 5403 If the parameter {item} evaluates to a String, it is used as a 5404 regular expression. All entries matching that expression will 5405 be removed from the history (if there are any). 5406 Upper/lowercase must match, unless "\c" is used |/\c|. 5407 If {item} evaluates to a Number, it will be interpreted as 5408 an index, see |:history-indexing|. The respective entry will 5409 be removed if it exists. 5410 5411 The result is TRUE for a successful operation, otherwise FALSE 5412 is returned. 5413 5414 Examples: 5415 Clear expression register history: >vim 5416 call histdel("expr") 5417 < 5418 Remove all entries starting with "*" from the search history: >vim 5419 call histdel("/", '^\*') 5420 < 5421 The following three are equivalent: >vim 5422 call histdel("search", histnr("search")) 5423 call histdel("search", -1) 5424 call histdel("search", '^' .. histget("search", -1) .. '$') 5425 < 5426 To delete the last search pattern and use the last-but-one for 5427 the "n" command and 'hlsearch': >vim 5428 call histdel("search", -1) 5429 let @/ = histget("search", -1) 5430 < 5431 ]=], 5432 name = 'histdel', 5433 params = { { 'history', 'string' }, { 'item', 'any' } }, 5434 returns = '0|1', 5435 signature = 'histdel({history} [, {item}])', 5436 }, 5437 histget = { 5438 args = { 1, 2 }, 5439 base = 1, 5440 desc = [=[ 5441 The result is a String, the entry with Number {index} from 5442 {history}. See |hist-names| for the possible values of 5443 {history}, and |:history-indexing| for {index}. If there is 5444 no such entry, an empty String is returned. When {index} is 5445 omitted, the most recent item from the history is used. 5446 5447 Examples: 5448 Redo the second last search from history. >vim 5449 execute '/' .. histget("search", -2) 5450 5451 <Define an Ex command ":H {num}" that supports re-execution of 5452 the {num}th entry from the output of |:history|. >vim 5453 command -nargs=1 H execute histget("cmd", 0+<args>) 5454 < 5455 ]=], 5456 name = 'histget', 5457 params = { { 'history', 'string' }, { 'index', 'integer|string' } }, 5458 returns = 'string', 5459 signature = 'histget({history} [, {index}])', 5460 }, 5461 histnr = { 5462 args = 1, 5463 base = 1, 5464 desc = [=[ 5465 The result is the Number of the current entry in {history}. 5466 See |hist-names| for the possible values of {history}. 5467 If an error occurred, -1 is returned. 5468 5469 Example: >vim 5470 let inp_index = histnr("expr") 5471 < 5472 5473 ]=], 5474 name = 'histnr', 5475 params = { { 'history', 'string' } }, 5476 returns = 'integer', 5477 signature = 'histnr({history})', 5478 }, 5479 hlID = { 5480 args = 1, 5481 base = 1, 5482 desc = [=[ 5483 The result is a Number, which is the ID of the highlight group 5484 with name {name}. When the highlight group doesn't exist, 5485 zero is returned. 5486 This can be used to retrieve information about the highlight 5487 group. For example, to get the background color of the 5488 "Comment" group: >vim 5489 echo synIDattr(synIDtrans(hlID("Comment")), "bg") 5490 < 5491 ]=], 5492 name = 'hlID', 5493 params = { { 'name', 'string' } }, 5494 returns = 'integer', 5495 signature = 'hlID({name})', 5496 }, 5497 hlexists = { 5498 args = 1, 5499 base = 1, 5500 desc = [=[ 5501 The result is a Number, which is TRUE if a highlight group 5502 called {name} exists. This is when the group has been 5503 defined in some way. Not necessarily when highlighting has 5504 been defined for it, it may also have been used for a syntax 5505 item. 5506 5507 ]=], 5508 name = 'hlexists', 5509 params = { { 'name', 'string' } }, 5510 returns = '0|1', 5511 signature = 'hlexists({name})', 5512 }, 5513 hostname = { 5514 desc = [=[ 5515 The result is a String, which is the name of the machine on 5516 which Vim is currently running. Machine names greater than 5517 256 characters long are truncated. 5518 ]=], 5519 fast = true, 5520 name = 'hostname', 5521 params = {}, 5522 returns = 'string', 5523 signature = 'hostname()', 5524 }, 5525 iconv = { 5526 args = 3, 5527 base = 1, 5528 desc = [=[ 5529 The result is a String, which is the text {string} converted 5530 from encoding {from} to encoding {to}. 5531 When the conversion completely fails an empty string is 5532 returned. When some characters could not be converted they 5533 are replaced with "?". 5534 The encoding names are whatever the iconv() library function 5535 can accept, see ":!man 3 iconv". 5536 Note that Vim uses UTF-8 for all Unicode encodings, conversion 5537 from/to UCS-2 is automatically changed to use UTF-8. You 5538 cannot use UCS-2 in a string anyway, because of the NUL bytes. 5539 5540 ]=], 5541 fast = true, 5542 name = 'iconv', 5543 params = { { 'string', 'string' }, { 'from', 'string' }, { 'to', 'string' } }, 5544 returns = 'string', 5545 signature = 'iconv({string}, {from}, {to})', 5546 }, 5547 id = { 5548 args = 1, 5549 desc = [=[ 5550 Returns a |String| which is a unique identifier of the 5551 container type (|List|, |Dict|, |Blob| and |Partial|). It is 5552 guaranteed that for the mentioned types `id(v1) ==# id(v2)` 5553 returns true iff `type(v1) == type(v2) && v1 is v2`. 5554 Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and 5555 `v:_null_blob` have the same `id()` with different types 5556 because they are internally represented as NULL pointers. 5557 `id()` returns a hexadecimal representation of the pointers to 5558 the containers (i.e. like `0x994a40`), same as `printf("%p", 5559 {expr})`, but it is advised against counting on the exact 5560 format of the return value. 5561 5562 It is not guaranteed that `id(no_longer_existing_container)` 5563 will not be equal to some other `id()`: new containers may 5564 reuse identifiers of the garbage-collected ones. 5565 ]=], 5566 name = 'id', 5567 params = { { 'expr', 'any' } }, 5568 returns = 'string', 5569 signature = 'id({expr})', 5570 }, 5571 indent = { 5572 args = 1, 5573 base = 1, 5574 desc = [=[ 5575 The result is a Number, which is indent of line {lnum} in the 5576 current buffer. The indent is counted in spaces, the value 5577 of 'tabstop' is relevant. {lnum} is used just like in 5578 |getline()|. 5579 When {lnum} is invalid -1 is returned. 5580 5581 To get or set indent of lines in a string, see |vim.text.indent()|. 5582 5583 ]=], 5584 name = 'indent', 5585 params = { { 'lnum', 'integer|string' } }, 5586 returns = 'integer', 5587 signature = 'indent({lnum})', 5588 }, 5589 index = { 5590 args = { 2, 4 }, 5591 base = 1, 5592 desc = [=[ 5593 Find {expr} in {object} and return its index. See 5594 |indexof()| for using a lambda to select the item. 5595 5596 If {object} is a |List| return the lowest index where the item 5597 has a value equal to {expr}. There is no automatic 5598 conversion, so the String "4" is different from the Number 4. 5599 And the Number 4 is different from the Float 4.0. The value 5600 of 'ignorecase' is not used here, case matters as indicated by 5601 the {ic} argument. 5602 5603 If {object} is a |Blob| return the lowest index where the byte 5604 value is equal to {expr}. 5605 5606 If {start} is given then start looking at the item with index 5607 {start} (may be negative for an item relative to the end). 5608 5609 When {ic} is given and it is |TRUE|, ignore case. Otherwise 5610 case must match. 5611 5612 -1 is returned when {expr} is not found in {object}. 5613 Example: >vim 5614 let idx = index(words, "the") 5615 if index(numbers, 123) >= 0 5616 " ... 5617 endif 5618 < 5619 5620 ]=], 5621 name = 'index', 5622 params = { { 'object', 'any' }, { 'expr', 'any' }, { 'start', 'integer' }, { 'ic', 'boolean' } }, 5623 returns = 'integer', 5624 signature = 'index({object}, {expr} [, {start} [, {ic}]])', 5625 }, 5626 indexof = { 5627 args = { 2, 3 }, 5628 base = 1, 5629 desc = [=[ 5630 Returns the index of an item in {object} where {expr} is 5631 v:true. {object} must be a |List| or a |Blob|. 5632 5633 If {object} is a |List|, evaluate {expr} for each item in the 5634 List until the expression is v:true and return the index of 5635 this item. 5636 5637 If {object} is a |Blob| evaluate {expr} for each byte in the 5638 Blob until the expression is v:true and return the index of 5639 this byte. 5640 5641 {expr} must be a |string| or |Funcref|. 5642 5643 If {expr} is a |string|: If {object} is a |List|, inside 5644 {expr} |v:key| has the index of the current List item and 5645 |v:val| has the value of the item. If {object} is a |Blob|, 5646 inside {expr} |v:key| has the index of the current byte and 5647 |v:val| has the byte value. 5648 5649 If {expr} is a |Funcref| it must take two arguments: 5650 1. the key or the index of the current item. 5651 2. the value of the current item. 5652 The function must return |TRUE| if the item is found and the 5653 search should stop. 5654 5655 The optional argument {opts} is a Dict and supports the 5656 following items: 5657 startidx start evaluating {expr} at the item with this 5658 index; may be negative for an item relative to 5659 the end 5660 Returns -1 when {expr} evaluates to v:false for all the items. 5661 Example: >vim 5662 let l = [#{n: 10}, #{n: 20}, #{n: 30}] 5663 echo indexof(l, "v:val.n == 20") 5664 echo indexof(l, {i, v -> v.n == 30}) 5665 echo indexof(l, "v:val.n == 20", #{startidx: 1}) 5666 < 5667 5668 ]=], 5669 name = 'indexof', 5670 params = { { 'object', 'any' }, { 'expr', 'any' }, { 'opts', 'table' } }, 5671 returns = 'integer', 5672 signature = 'indexof({object}, {expr} [, {opts}])', 5673 }, 5674 input = { 5675 args = { 1, 3 }, 5676 base = 1, 5677 desc = '', 5678 name = 'input', 5679 params = { { 'prompt', 'string' }, { 'text', 'string' }, { 'completion', 'string' } }, 5680 returns = 'string', 5681 signature = 'input({prompt} [, {text} [, {completion}]])', 5682 }, 5683 input__1 = { 5684 args = { 1, 3 }, 5685 base = 1, 5686 desc = [=[ 5687 The result is a String, which is whatever the user typed on 5688 the command-line. The {prompt} argument is either a prompt 5689 string, or a blank string (for no prompt). A '\n' can be used 5690 in the prompt to start a new line. 5691 5692 In the second form it accepts a single dictionary with the 5693 following keys, any of which may be omitted: 5694 5695 Key Default Description ~ 5696 prompt "" Same as {prompt} in the first form. 5697 default "" Same as {text} in the first form. 5698 completion nothing Same as {completion} in the first form. 5699 cancelreturn "" The value returned when the dialog is 5700 cancelled. 5701 highlight nothing Highlight handler: |Funcref|. 5702 5703 The highlighting set with |:echohl| is used for the prompt. 5704 The input is entered just like a command-line, with the same 5705 editing commands and mappings. There is a separate history 5706 for lines typed for input(). 5707 Example: >vim 5708 if input("Coffee or beer? ") == "beer" 5709 echo "Cheers!" 5710 endif 5711 < 5712 If the optional {text} argument is present and not empty, this 5713 is used for the default reply, as if the user typed this. 5714 Example: >vim 5715 let color = input("Color? ", "white") 5716 5717 <The optional {completion} argument specifies the type of 5718 completion supported for the input. Without it completion is 5719 not performed. The supported completion types are the same as 5720 that can be supplied to a user-defined command using the 5721 "-complete=" argument. Refer to |:command-completion| for 5722 more information. Example: >vim 5723 let fname = input("File: ", "", "file") 5724 5725 < *input()-highlight* *E5400* *E5402* 5726 The optional `highlight` key allows specifying function which 5727 will be used for highlighting user input. This function 5728 receives user input as its only argument and must return 5729 a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group] 5730 where 5731 hl_start_col is the first highlighted column, 5732 hl_end_col is the last highlighted column (+ 1!), 5733 hl_group is |:hi| group used for highlighting. 5734 *E5403* *E5404* *E5405* *E5406* 5735 Both hl_start_col and hl_end_col + 1 must point to the start 5736 of the multibyte character (highlighting must not break 5737 multibyte characters), hl_end_col + 1 may be equal to the 5738 input length. Start column must be in range [0, len(input)), 5739 end column must be in range (hl_start_col, len(input)], 5740 sections must be ordered so that next hl_start_col is greater 5741 then or equal to previous hl_end_col. 5742 5743 Example (try some input with parentheses): >vim 5744 highlight RBP1 guibg=Red ctermbg=red 5745 highlight RBP2 guibg=Yellow ctermbg=yellow 5746 highlight RBP3 guibg=Green ctermbg=green 5747 highlight RBP4 guibg=Blue ctermbg=blue 5748 let g:rainbow_levels = 4 5749 function! RainbowParens(cmdline) 5750 let ret = [] 5751 let i = 0 5752 let lvl = 0 5753 while i < len(a:cmdline) 5754 if a:cmdline[i] is# '(' 5755 call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) 5756 let lvl += 1 5757 elseif a:cmdline[i] is# ')' 5758 let lvl -= 1 5759 call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) 5760 endif 5761 let i += 1 5762 endwhile 5763 return ret 5764 endfunction 5765 call input({'prompt':'>','highlight':'RainbowParens'}) 5766 < 5767 Highlight function is called at least once for each new 5768 displayed input string, before command-line is redrawn. It is 5769 expected that function is pure for the duration of one input() 5770 call, i.e. it produces the same output for the same input, so 5771 output may be memoized. Function is run like under |:silent| 5772 modifier. If the function causes any errors, it will be 5773 skipped for the duration of the current input() call. 5774 5775 Highlighting is disabled if command-line contains arabic 5776 characters. 5777 5778 NOTE: This function must not be used in a startup file, for 5779 the versions that only run in GUI mode (e.g., the Win32 GUI). 5780 Note: When input() is called from within a mapping it will 5781 consume remaining characters from that mapping, because a 5782 mapping is handled like the characters were typed. 5783 Use |inputsave()| before input() and |inputrestore()| 5784 after input() to avoid that. Another solution is to avoid 5785 that further characters follow in the mapping, e.g., by using 5786 |:execute| or |:normal|. 5787 5788 Example with a mapping: >vim 5789 nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR> 5790 function GetFoo() 5791 call inputsave() 5792 let g:Foo = input("enter search pattern: ") 5793 call inputrestore() 5794 endfunction 5795 < 5796 5797 ]=], 5798 name = 'input', 5799 params = { { 'opts', 'table' } }, 5800 returns = 'string', 5801 signature = 'input({opts})', 5802 }, 5803 inputdialog = { 5804 args = { 1, 3 }, 5805 base = 1, 5806 deprecated = true, 5807 desc = [=[ 5808 Use |input()| instead. 5809 ]=], 5810 params = VARARGS, 5811 signature = 'input(...)', 5812 }, 5813 inputlist = { 5814 args = 1, 5815 base = 1, 5816 desc = [=[ 5817 {textlist} must be a |List| of strings. This |List| is 5818 displayed, one string per line. The user will be prompted to 5819 enter a number, which is returned. 5820 The user can also select an item by clicking on it with the 5821 mouse, if the mouse is enabled in the command line ('mouse' is 5822 "a" or includes "c"). For the first string 0 is returned. 5823 When clicking above the first item a negative number is 5824 returned. When clicking on the prompt one more than the 5825 length of {textlist} is returned. 5826 Make sure {textlist} has less than 'lines' entries, otherwise 5827 it won't work. It's a good idea to put the entry number at 5828 the start of the string. And put a prompt in the first item. 5829 Example: >vim 5830 let color = inputlist(['Select color:', '1. red', 5831 \ '2. green', '3. blue']) 5832 < 5833 ]=], 5834 name = 'inputlist', 5835 params = { { 'textlist', 'string[]' } }, 5836 signature = 'inputlist({textlist})', 5837 }, 5838 inputrestore = { 5839 desc = [=[ 5840 Restore typeahead that was saved with a previous |inputsave()|. 5841 Should be called the same number of times |inputsave()| is 5842 called. Calling it more often is harmless though. 5843 Returns TRUE when there is nothing to restore, FALSE 5844 otherwise. 5845 ]=], 5846 name = 'inputrestore', 5847 params = {}, 5848 returns = 'integer', 5849 signature = 'inputrestore()', 5850 }, 5851 inputsave = { 5852 desc = [=[ 5853 Preserve typeahead (also from mappings) and clear it, so that 5854 a following prompt gets input from the user. Should be 5855 followed by a matching |inputrestore()| after the prompt. Can 5856 be used several times, in which case there must be just as 5857 many |inputrestore()| calls. 5858 Returns TRUE when out of memory, FALSE otherwise. 5859 ]=], 5860 name = 'inputsave', 5861 params = {}, 5862 returns = 'integer', 5863 signature = 'inputsave()', 5864 }, 5865 inputsecret = { 5866 args = { 1, 2 }, 5867 base = 1, 5868 desc = [=[ 5869 This function acts much like the |input()| function with but 5870 two exceptions: 5871 a) the user's response will be displayed as a sequence of 5872 asterisks ("*") thereby keeping the entry secret, and 5873 b) the user's response will not be recorded on the input 5874 |history| stack. 5875 The result is a String, which is whatever the user actually 5876 typed on the command-line in response to the issued prompt. 5877 NOTE: Command-line completion is not supported. 5878 5879 ]=], 5880 name = 'inputsecret', 5881 params = { { 'prompt', 'string' }, { 'text', 'string' } }, 5882 returns = 'string', 5883 signature = 'inputsecret({prompt} [, {text}])', 5884 }, 5885 insert = { 5886 args = { 2, 3 }, 5887 base = 1, 5888 desc = [=[ 5889 When {object} is a |List| or a |Blob| insert {item} at the start 5890 of it. 5891 5892 If {idx} is specified insert {item} before the item with index 5893 {idx}. If {idx} is zero it goes before the first item, just 5894 like omitting {idx}. A negative {idx} is also possible, see 5895 |list-index|. -1 inserts just before the last item. 5896 5897 Returns the resulting |List| or |Blob|. Examples: >vim 5898 let mylist = insert([2, 3, 5], 1) 5899 call insert(mylist, 4, -1) 5900 call insert(mylist, 6, len(mylist)) 5901 <The last example can be done simpler with |add()|. 5902 Note that when {item} is a |List| it is inserted as a single 5903 item. Use |extend()| to concatenate |Lists|. 5904 5905 ]=], 5906 name = 'insert', 5907 params = { { 'object', 'any' }, { 'item', 'any' }, { 'idx', 'integer' } }, 5908 signature = 'insert({object}, {item} [, {idx}])', 5909 }, 5910 interrupt = { 5911 args = 0, 5912 desc = [=[ 5913 Interrupt script execution. It works more or less like the 5914 user typing CTRL-C, most commands won't execute and control 5915 returns to the user. This is useful to abort execution 5916 from lower down, e.g. in an autocommand. Example: >vim 5917 function s:check_typoname(file) 5918 if fnamemodify(a:file, ':t') == '[' 5919 echomsg 'Maybe typo' 5920 call interrupt() 5921 endif 5922 endfunction 5923 au BufWritePre * call s:check_typoname(expand('<amatch>')) 5924 < 5925 ]=], 5926 name = 'interrupt', 5927 params = {}, 5928 signature = 'interrupt()', 5929 }, 5930 invert = { 5931 args = 1, 5932 base = 1, 5933 desc = [=[ 5934 Bitwise invert. The argument is converted to a number. A 5935 List, Dict or Float argument causes an error. Example: >vim 5936 let bits = invert(bits) 5937 < 5938 ]=], 5939 name = 'invert', 5940 params = { { 'expr', 'integer' } }, 5941 returns = 'integer', 5942 signature = 'invert({expr})', 5943 }, 5944 isabsolutepath = { 5945 args = 1, 5946 base = 1, 5947 desc = [=[ 5948 The result is a Number, which is |TRUE| when {path} is an 5949 absolute path. 5950 On Unix, a path is considered absolute when it starts with 5951 '/'. 5952 On MS-Windows, it is considered absolute when it starts with 5953 an optional drive prefix and is followed by a '\' or '/'. UNC 5954 paths are always absolute. 5955 Example: >vim 5956 echo isabsolutepath('/usr/share/') " 1 5957 echo isabsolutepath('./foobar') " 0 5958 echo isabsolutepath('C:\Windows') " 1 5959 echo isabsolutepath('foobar') " 0 5960 echo isabsolutepath('\\remote\file') " 1 5961 < 5962 ]=], 5963 fast = true, 5964 name = 'isabsolutepath', 5965 params = { { 'path', 'string' } }, 5966 returns = '0|1', 5967 signature = 'isabsolutepath({path})', 5968 }, 5969 isdirectory = { 5970 args = 1, 5971 base = 1, 5972 desc = [=[ 5973 The result is a Number, which is |TRUE| when a directory 5974 with the name {directory} exists. If {directory} doesn't 5975 exist, or isn't a directory, the result is |FALSE|. {directory} 5976 is any expression, which is used as a String. 5977 5978 ]=], 5979 fast = true, 5980 name = 'isdirectory', 5981 params = { { 'directory', 'string' } }, 5982 returns = '0|1', 5983 signature = 'isdirectory({directory})', 5984 }, 5985 isinf = { 5986 args = 1, 5987 base = 1, 5988 desc = [=[ 5989 Return 1 if {expr} is a positive infinity, or -1 a negative 5990 infinity, otherwise 0. >vim 5991 echo isinf(1.0 / 0.0) 5992 < 1 >vim 5993 echo isinf(-1.0 / 0.0) 5994 < -1 5995 5996 ]=], 5997 name = 'isinf', 5998 params = { { 'expr', 'number' } }, 5999 returns = '1|0|-1', 6000 signature = 'isinf({expr})', 6001 }, 6002 islocked = { 6003 args = 1, 6004 base = 1, 6005 desc = [=[ 6006 The result is a Number, which is |TRUE| when {expr} is the 6007 name of a locked variable. 6008 The string argument {expr} must be the name of a variable, 6009 |List| item or |Dictionary| entry, not the variable itself! 6010 Example: >vim 6011 let alist = [0, ['a', 'b'], 2, 3] 6012 lockvar 1 alist 6013 echo islocked('alist') " 1 6014 echo islocked('alist[1]') " 0 6015 6016 <When {expr} is a variable that does not exist you get an error 6017 message. Use |exists()| to check for existence. 6018 6019 ]=], 6020 name = 'islocked', 6021 params = { { 'expr', 'any' } }, 6022 returns = '0|1', 6023 signature = 'islocked({expr})', 6024 tags = { 'E786' }, 6025 }, 6026 isnan = { 6027 args = 1, 6028 base = 1, 6029 desc = [=[ 6030 Return |TRUE| if {expr} is a float with value NaN. >vim 6031 echo isnan(0.0 / 0.0) 6032 < 1 6033 6034 ]=], 6035 name = 'isnan', 6036 params = { { 'expr', 'number' } }, 6037 returns = '0|1', 6038 signature = 'isnan({expr})', 6039 }, 6040 items = { 6041 args = 1, 6042 base = 1, 6043 desc = [=[ 6044 Return a |List| with all key/index and value pairs of {expr}. 6045 Each |List| item is a list with two items: 6046 - for a |Dict|: the key and the value 6047 - for a |List|, |Blob| or |String|: the index and the value 6048 The returned |List| is in arbitrary order for a |Dict|, 6049 otherwise it's in ascending order of the index. 6050 6051 Also see |keys()| and |values()|. 6052 6053 Example: >vim 6054 let mydict = #{a: 'red', b: 'blue'} 6055 for [key, value] in items(mydict) 6056 echo $"{key} = {value}" 6057 endfor 6058 echo items([1, 2, 3]) 6059 echo items("foobar") 6060 echo items(0z0102) 6061 < 6062 ]=], 6063 name = 'items', 6064 params = { { 'expr', 'table|string' } }, 6065 signature = 'items({expr})', 6066 }, 6067 jobclose = { 6068 args = { 1, 2 }, 6069 deprecated = true, 6070 desc = [=[ 6071 Obsolete name for |chanclose()| 6072 ]=], 6073 func = 'f_chanclose', 6074 params = VARARGS, 6075 signature = 'jobclose({id} [, {stream}])', 6076 }, 6077 jobpid = { 6078 args = 1, 6079 desc = [=[ 6080 Return the PID (process id) of |job-id| {job}. 6081 ]=], 6082 name = 'jobpid', 6083 params = { { 'job', 'integer' } }, 6084 returns = 'integer', 6085 signature = 'jobpid({job})', 6086 }, 6087 jobresize = { 6088 args = 3, 6089 desc = [=[ 6090 Resize the pseudo terminal window of |job-id| {job} to {width} 6091 columns and {height} rows. 6092 Fails if the job was not started with `"pty":v:true`. 6093 ]=], 6094 name = 'jobresize', 6095 params = { { 'job', 'integer' }, { 'width', 'integer' }, { 'height', 'integer' } }, 6096 signature = 'jobresize({job}, {width}, {height})', 6097 }, 6098 jobsend = { 6099 args = 2, 6100 deprecated = true, 6101 desc = [=[ 6102 Obsolete name for |chansend()| 6103 ]=], 6104 func = 'f_chansend', 6105 params = VARARGS, 6106 signature = 'jobsend({id}, {data})', 6107 }, 6108 jobstart = { 6109 args = { 1, 2 }, 6110 desc = [=[ 6111 Note: Prefer |vim.system()| in Lua (unless using `rpc`, `pty`, or `term`). 6112 6113 Spawns {cmd} as a job. 6114 If {cmd} is a List it runs directly (no 'shell'). 6115 If {cmd} is a String it runs in the 'shell', like this: >vim 6116 call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) 6117 <(See |shell-unquoting| for details.) 6118 6119 Example: start a job and handle its output: >vim 6120 call jobstart(['nvim', '-h'], {'on_stdout':{j,d,e->append(line('.'),d)}}) 6121 < 6122 Example: start a job in a |terminal| connected to the current buffer: >vim 6123 call jobstart(['nvim', '-h'], {'term':v:true}) 6124 < 6125 Returns |job-id| on success, 0 on invalid arguments (or job 6126 table is full), -1 if {cmd}[0] or 'shell' is not executable. 6127 The returned job-id is a valid |channel-id| representing the 6128 job's stdio streams. Use |chansend()| (or |rpcnotify()| and 6129 |rpcrequest()| if "rpc" was enabled) to send data to stdin and 6130 |chanclose()| to close the streams without stopping the job. 6131 6132 See |job-control| and |RPC|. 6133 6134 NOTE: on Windows if {cmd} is a List: 6135 - cmd[0] must be an executable (not a "built-in"). If it is 6136 in $PATH it can be called by name, without an extension: >vim 6137 call jobstart(['ping', 'neovim.io']) 6138 < If it is a full or partial path, extension is required: >vim 6139 call jobstart(['System32\ping.exe', 'neovim.io']) 6140 < - {cmd} is collapsed to a string of quoted args as expected 6141 by CommandLineToArgvW https://msdn.microsoft.com/bb776391 6142 unless cmd[0] is some form of "cmd.exe". 6143 6144 *jobstart-env* 6145 The job environment is initialized as follows: 6146 $NVIM is set to |v:servername| of the parent Nvim 6147 $NVIM_LISTEN_ADDRESS is unset 6148 $NVIM_LOG_FILE is unset 6149 $VIM is unset 6150 $VIMRUNTIME is unset 6151 You can set these with the `env` option. 6152 6153 *jobstart-options* 6154 {opts} is a dictionary with these keys: 6155 clear_env: (boolean) `env` defines the job environment 6156 exactly, instead of merging current environment. 6157 cwd: (string, default=|current-directory|) Working 6158 directory of the job. 6159 detach: (boolean) Detach the job process: it will not be 6160 killed when Nvim exits. If the process exits 6161 before Nvim, `on_exit` will be invoked. 6162 env: (dict) Map of environment variable name:value 6163 pairs extending (or replace with "clear_env") 6164 the current environment. |jobstart-env| 6165 height: (number) Height of the `pty` terminal. 6166 |on_exit|: (function) Callback invoked when the job exits. 6167 |on_stdout|: (function) Callback invoked when the job emits 6168 stdout data. 6169 |on_stderr|: (function) Callback invoked when the job emits 6170 stderr data. 6171 overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the 6172 stdio passed to the child process. Only on 6173 MS-Windows; ignored on other platforms. 6174 pty: (boolean) Connect the job to a new pseudo 6175 terminal, and its streams to the master file 6176 descriptor. `on_stdout` receives all output, 6177 `on_stderr` is ignored. |terminal-start| 6178 rpc: (boolean) Use |msgpack-rpc| to communicate with 6179 the job over stdio. Then `on_stdout` is ignored, 6180 but `on_stderr` can still be used. 6181 stderr_buffered: (boolean) Collect data until EOF (stream closed) 6182 before invoking `on_stderr`. |channel-buffered| 6183 stdout_buffered: (boolean) Collect data until EOF (stream 6184 closed) before invoking `on_stdout`. |channel-buffered| 6185 stdin: (string) Either "pipe" (default) to connect the 6186 job's stdin to a channel or "null" to disconnect 6187 stdin. 6188 term: (boolean) Spawns {cmd} in a new pseudo-terminal session 6189 connected to the current (unmodified) buffer. Implies "pty". 6190 Default "height" and "width" are set to the current window 6191 dimensions. |jobstart()|. Defaults $TERM to "xterm-256color". 6192 width: (number) Width of the `pty` terminal. 6193 6194 {opts} is passed as |self| dictionary to the callback; the 6195 caller may set other keys to pass application-specific data. 6196 6197 Returns: 6198 - |channel-id| on success 6199 - 0 on invalid arguments 6200 - -1 if {cmd}[0] is not executable. 6201 See also |job-control|, |channel|, |msgpack-rpc|. 6202 ]=], 6203 name = 'jobstart', 6204 params = { { 'cmd', 'string|string[]' }, { 'opts', 'table' } }, 6205 returns = 'integer', 6206 signature = 'jobstart({cmd} [, {opts}])', 6207 }, 6208 jobstop = { 6209 args = 1, 6210 desc = [=[ 6211 Stop |job-id| {id} by sending SIGTERM to the job process. If 6212 the process does not terminate after a timeout then SIGKILL 6213 will be sent. When the job terminates its |on_exit| handler 6214 (if any) will be invoked. 6215 See |job-control|. 6216 6217 Returns 1 for valid job id, 0 for invalid id, including jobs have 6218 exited or stopped. 6219 ]=], 6220 name = 'jobstop', 6221 params = { { 'id', 'integer' } }, 6222 returns = 'integer', 6223 signature = 'jobstop({id})', 6224 }, 6225 jobwait = { 6226 args = { 1, 2 }, 6227 desc = [=[ 6228 Waits for jobs and their |on_exit| handlers to complete. 6229 6230 {jobs} is a List of |job-id|s to wait for. 6231 {timeout} is the maximum waiting time in milliseconds. If 6232 omitted or -1, wait forever. 6233 6234 Timeout of 0 can be used to check the status of a job: >vim 6235 let running = jobwait([{job-id}], 0)[0] == -1 6236 < 6237 During jobwait() callbacks for jobs not in the {jobs} list may 6238 be invoked. The screen will not redraw unless |:redraw| is 6239 invoked by a callback. 6240 6241 Returns a list of len({jobs}) integers, where each integer is 6242 the status of the corresponding job: 6243 Exit-code, if the job exited 6244 -1 if the timeout was exceeded 6245 -2 if the job was interrupted (by |CTRL-C|) 6246 -3 if the job-id is invalid 6247 ]=], 6248 name = 'jobwait', 6249 params = { { 'jobs', 'integer[]' }, { 'timeout', 'integer' } }, 6250 returns = 'integer[]', 6251 signature = 'jobwait({jobs} [, {timeout}])', 6252 }, 6253 join = { 6254 args = { 1, 2 }, 6255 base = 1, 6256 desc = [=[ 6257 Join the items in {list} together into one String. 6258 When {sep} is specified it is put in between the items. If 6259 {sep} is omitted a single space is used. 6260 Note that {sep} is not added at the end. You might want to 6261 add it there too: >vim 6262 let lines = join(mylist, "\n") .. "\n" 6263 <String items are used as-is. |Lists| and |Dictionaries| are 6264 converted into a string like with |string()|. 6265 The opposite function is |split()|. 6266 6267 ]=], 6268 name = 'join', 6269 params = { { 'list', 'any[]' }, { 'sep', 'string' } }, 6270 returns = 'string', 6271 signature = 'join({list} [, {sep}])', 6272 }, 6273 json_decode = { 6274 args = 1, 6275 base = 1, 6276 desc = [=[ 6277 Convert {expr} from JSON object. Accepts |readfile()|-style 6278 list as the input, as well as regular string. May output any 6279 Vim value. In the following cases it will output 6280 |msgpack-special-dict|: 6281 1. Dictionary contains duplicate key. 6282 2. String contains NUL byte. Two special dictionaries: for 6283 dictionary and for string will be emitted in case string 6284 with NUL byte was a dictionary key. 6285 6286 Note: function treats its input as UTF-8 always. The JSON 6287 standard allows only a few encodings, of which UTF-8 is 6288 recommended and the only one required to be supported. 6289 Non-UTF-8 characters are an error. 6290 6291 ]=], 6292 name = 'json_decode', 6293 params = { { 'expr', 'any' } }, 6294 signature = 'json_decode({expr})', 6295 }, 6296 json_encode = { 6297 args = 1, 6298 base = 1, 6299 desc = [=[ 6300 Convert {expr} into a JSON string. Accepts 6301 |msgpack-special-dict| as the input. Will not convert 6302 |Funcref|s, mappings with non-string keys (can be created as 6303 |msgpack-special-dict|), values with self-referencing 6304 containers, strings which contain non-UTF-8 characters, 6305 pseudo-UTF-8 strings which contain codepoints reserved for 6306 surrogate pairs (such strings are not valid UTF-8 strings). 6307 Non-printable characters are converted into "\u1234" escapes 6308 or special escapes like "\t", other are dumped as-is. 6309 |Blob|s are converted to arrays of the individual bytes. 6310 6311 ]=], 6312 name = 'json_encode', 6313 params = { { 'expr', 'any' } }, 6314 returns = 'string', 6315 signature = 'json_encode({expr})', 6316 }, 6317 keys = { 6318 args = 1, 6319 base = 1, 6320 desc = [=[ 6321 Return a |List| with all the keys of {dict}. The |List| is in 6322 arbitrary order. Also see |items()| and |values()|. 6323 6324 ]=], 6325 name = 'keys', 6326 params = { { 'dict', 'table' } }, 6327 returns = 'string[]', 6328 signature = 'keys({dict})', 6329 }, 6330 keytrans = { 6331 args = 1, 6332 base = 1, 6333 desc = [=[ 6334 Turn the internal byte representation of keys into a form that 6335 can be used for |:map|. E.g. >vim 6336 let xx = "\<C-Home>" 6337 echo keytrans(xx) 6338 < <C-Home> 6339 6340 ]=], 6341 name = 'keytrans', 6342 params = { { 'string', 'string' } }, 6343 returns = 'string', 6344 signature = 'keytrans({string})', 6345 }, 6346 last_buffer_nr = { 6347 deprecated = true, 6348 desc = [=[ 6349 Obsolete name for bufnr("$"). 6350 ]=], 6351 params = {}, 6352 signature = 'last_buffer_nr()', 6353 }, 6354 len = { 6355 args = 1, 6356 base = 1, 6357 desc = [=[ 6358 The result is a Number, which is the length of the argument. 6359 When {expr} is a String or a Number the length in bytes is 6360 used, as with |strlen()|. 6361 When {expr} is a |List| the number of items in the |List| is 6362 returned. 6363 When {expr} is a |Blob| the number of bytes is returned. 6364 When {expr} is a |Dictionary| the number of entries in the 6365 |Dictionary| is returned. 6366 Otherwise an error is given and returns zero. 6367 6368 ]=], 6369 name = 'len', 6370 params = { { 'expr', 'any[]' } }, 6371 returns = 'integer', 6372 signature = 'len({expr})', 6373 tags = { 'E701' }, 6374 }, 6375 libcall = { 6376 args = 3, 6377 base = 3, 6378 desc = [=[ 6379 Call function {funcname} in the run-time library {libname} 6380 with single argument {argument}. 6381 This is useful to call functions in a library that you 6382 especially made to be used with Vim. Since only one argument 6383 is possible, calling standard library functions is rather 6384 limited. 6385 The result is the String returned by the function. If the 6386 function returns NULL, this will appear as an empty string "" 6387 to Vim. 6388 If the function returns a number, use |libcallnr()|! 6389 If {argument} is a number, it is passed to the function as an 6390 int; if {argument} is a string, it is passed as a 6391 null-terminated string. 6392 6393 libcall() allows you to write your own 'plug-in' extensions to 6394 Vim without having to recompile the program. It is NOT a 6395 means to call system functions! If you try to do so Vim will 6396 very probably crash. 6397 6398 For Win32, the functions you write must be placed in a DLL 6399 and use the normal C calling convention (NOT Pascal which is 6400 used in Windows System DLLs). The function must take exactly 6401 one parameter, either a character pointer or a long integer, 6402 and must return a character pointer or NULL. The character 6403 pointer returned must point to memory that will remain valid 6404 after the function has returned (e.g. in static data in the 6405 DLL). If it points to allocated memory, that memory will 6406 leak away. Using a static buffer in the function should work, 6407 it's then freed when the DLL is unloaded. 6408 6409 WARNING: If the function returns a non-valid pointer, Vim may 6410 crash! This also happens if the function returns a number, 6411 because Vim thinks it's a pointer. 6412 For Win32 systems, {libname} should be the filename of the DLL 6413 without the ".DLL" suffix. A full path is only required if 6414 the DLL is not in the usual places. 6415 For Unix: When compiling your own plugins, remember that the 6416 object code must be compiled as position-independent ('PIC'). 6417 Examples: >vim 6418 echo libcall("libc.so", "getenv", "HOME") 6419 < 6420 ]=], 6421 name = 'libcall', 6422 params = { { 'libname', 'string' }, { 'funcname', 'string' }, { 'argument', 'any' } }, 6423 signature = 'libcall({libname}, {funcname}, {argument})', 6424 tags = { 'E364', 'E368' }, 6425 }, 6426 libcallnr = { 6427 args = 3, 6428 base = 3, 6429 desc = [=[ 6430 Just like |libcall()|, but used for a function that returns an 6431 int instead of a string. 6432 Examples: >vim 6433 echo libcallnr("/usr/lib/libc.so", "getpid", "") 6434 call libcallnr("libc.so", "printf", "Hello World!\n") 6435 call libcallnr("libc.so", "sleep", 10) 6436 < 6437 ]=], 6438 name = 'libcallnr', 6439 params = { { 'libname', 'string' }, { 'funcname', 'string' }, { 'argument', 'any' } }, 6440 signature = 'libcallnr({libname}, {funcname}, {argument})', 6441 }, 6442 line = { 6443 args = { 1, 2 }, 6444 base = 1, 6445 desc = [=[ 6446 See |getpos()| for accepted positions. 6447 6448 To get the column number use |col()|. To get both use 6449 |getpos()|. 6450 6451 With the optional {winid} argument the values are obtained for 6452 that window instead of the current window. 6453 6454 Returns 0 for invalid values of {expr} and {winid}. 6455 6456 Examples: >vim 6457 echo line(".") " line number of the cursor 6458 echo line(".", winid) " idem, in window "winid" 6459 echo line("'t") " line number of mark t 6460 echo line("'" .. marker) " line number of mark marker 6461 < 6462 To jump to the last known position when opening a file see 6463 |last-position-jump|. 6464 6465 ]=], 6466 name = 'line', 6467 params = { { 'expr', 'string|integer[]' }, { 'winid', 'integer' } }, 6468 returns = 'integer', 6469 signature = 'line({expr} [, {winid}])', 6470 }, 6471 line2byte = { 6472 args = 1, 6473 base = 1, 6474 desc = [=[ 6475 Return the byte count from the start of the buffer for line 6476 {lnum}. This includes the end-of-line character, depending on 6477 the 'fileformat' option for the current buffer. The first 6478 line returns 1. UTF-8 encoding is used, 'fileencoding' is 6479 ignored. This can also be used to get the byte count for the 6480 line just below the last line: >vim 6481 echo line2byte(line("$") + 1) 6482 <This is the buffer size plus one. If 'fileencoding' is empty 6483 it is the file size plus one. {lnum} is used like with 6484 |getline()|. When {lnum} is invalid -1 is returned. 6485 Also see |byte2line()|, |go| and |:goto|. 6486 6487 ]=], 6488 name = 'line2byte', 6489 params = { { 'lnum', 'integer|string' } }, 6490 returns = 'integer', 6491 signature = 'line2byte({lnum})', 6492 }, 6493 lispindent = { 6494 args = 1, 6495 base = 1, 6496 desc = [=[ 6497 Get the amount of indent for line {lnum} according the lisp 6498 indenting rules, as with 'lisp'. 6499 The indent is counted in spaces, the value of 'tabstop' is 6500 relevant. {lnum} is used just like in |getline()|. 6501 When {lnum} is invalid, -1 is returned. 6502 6503 ]=], 6504 name = 'lispindent', 6505 params = { { 'lnum', 'integer|string' } }, 6506 returns = 'integer', 6507 signature = 'lispindent({lnum})', 6508 }, 6509 list2blob = { 6510 args = 1, 6511 base = 1, 6512 desc = [=[ 6513 Return a Blob concatenating all the number values in {list}. 6514 Examples: >vim 6515 echo list2blob([1, 2, 3, 4]) " returns 0z01020304 6516 echo list2blob([]) " returns 0z 6517 <Returns an empty Blob on error. If one of the numbers is 6518 negative or more than 255 error *E1239* is given. 6519 6520 |blob2list()| does the opposite. 6521 6522 ]=], 6523 name = 'list2blob', 6524 params = { { 'list', 'any[]' } }, 6525 returns = 'string', 6526 signature = 'list2blob({list})', 6527 }, 6528 list2str = { 6529 args = { 1, 2 }, 6530 base = 1, 6531 desc = [=[ 6532 Convert each number in {list} to a character string can 6533 concatenate them all. Examples: >vim 6534 echo list2str([32]) " returns " " 6535 echo list2str([65, 66, 67]) " returns "ABC" 6536 <The same can be done (slowly) with: >vim 6537 echo join(map(list, {nr, val -> nr2char(val)}), '') 6538 <|str2list()| does the opposite. 6539 6540 UTF-8 encoding is always used, {utf8} option has no effect, 6541 and exists only for backwards-compatibility. 6542 With UTF-8 composing characters work as expected: >vim 6543 echo list2str([97, 769]) " returns "á" 6544 < 6545 Returns an empty string on error. 6546 6547 ]=], 6548 name = 'list2str', 6549 params = { { 'list', 'any[]' }, { 'utf8', 'boolean' } }, 6550 returns = 'string', 6551 signature = 'list2str({list} [, {utf8}])', 6552 }, 6553 localtime = { 6554 desc = [=[ 6555 Return the current time, measured as seconds since 1st Jan 6556 1970. See also |strftime()|, |strptime()| and |getftime()|. 6557 ]=], 6558 name = 'localtime', 6559 params = {}, 6560 returns = 'integer', 6561 signature = 'localtime()', 6562 }, 6563 log = { 6564 args = 1, 6565 base = 1, 6566 desc = [=[ 6567 Return the natural logarithm (base e) of {expr} as a |Float|. 6568 {expr} must evaluate to a |Float| or a |Number| in the range 6569 (0, inf]. 6570 Returns 0.0 if {expr} is not a |Float| or a |Number|. 6571 Examples: >vim 6572 echo log(10) 6573 < 2.302585 >vim 6574 echo log(exp(5)) 6575 < 5.0 6576 6577 ]=], 6578 float_func = 'log', 6579 name = 'log', 6580 params = { { 'expr', 'number' } }, 6581 returns = 'number', 6582 signature = 'log({expr})', 6583 }, 6584 log10 = { 6585 args = 1, 6586 base = 1, 6587 desc = [=[ 6588 Return the logarithm of Float {expr} to base 10 as a |Float|. 6589 {expr} must evaluate to a |Float| or a |Number|. 6590 Returns 0.0 if {expr} is not a |Float| or a |Number|. 6591 Examples: >vim 6592 echo log10(1000) 6593 < 3.0 >vim 6594 echo log10(0.01) 6595 < -2.0 6596 6597 ]=], 6598 float_func = 'log10', 6599 name = 'log10', 6600 params = { { 'expr', 'number' } }, 6601 returns = 'number', 6602 signature = 'log10({expr})', 6603 }, 6604 luaeval = { 6605 args = { 1, 2 }, 6606 base = 1, 6607 desc = [=[ 6608 Evaluate Lua expression {expr} and return its result converted 6609 to Vim data structures. See |lua-eval| for details. 6610 6611 See also |v:lua-call|. 6612 6613 ]=], 6614 lua = false, 6615 name = 'luaeval', 6616 params = { { 'expr', 'string' }, { 'expr', 'any[]' } }, 6617 signature = 'luaeval({expr} [, {expr}])', 6618 }, 6619 map = { 6620 args = 2, 6621 base = 1, 6622 desc = [=[ 6623 {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. 6624 When {expr1} is a |List| or |Dictionary|, replace each 6625 item in {expr1} with the result of evaluating {expr2}. 6626 For a |Blob| each byte is replaced. 6627 For a |String|, each character, including composing 6628 characters, is replaced. 6629 If the item type changes you may want to use |mapnew()| to 6630 create a new List or Dictionary. 6631 6632 {expr2} must be a |String| or |Funcref|. 6633 6634 If {expr2} is a |String|, inside {expr2} |v:val| has the value 6635 of the current item. For a |Dictionary| |v:key| has the key 6636 of the current item and for a |List| |v:key| has the index of 6637 the current item. For a |Blob| |v:key| has the index of the 6638 current byte. For a |String| |v:key| has the index of the 6639 current character. 6640 Example: >vim 6641 call map(mylist, '"> " .. v:val .. " <"') 6642 <This puts "> " before and " <" after each item in "mylist". 6643 6644 Note that {expr2} is the result of an expression and is then 6645 used as an expression again. Often it is good to use a 6646 |literal-string| to avoid having to double backslashes. You 6647 still have to double ' quotes 6648 6649 If {expr2} is a |Funcref| it is called with two arguments: 6650 1. The key or the index of the current item. 6651 2. the value of the current item. 6652 The function must return the new value of the item. Example 6653 that changes each value by "key-value": >vim 6654 func KeyValue(key, val) 6655 return a:key .. '-' .. a:val 6656 endfunc 6657 call map(myDict, function('KeyValue')) 6658 <It is shorter when using a |lambda|: >vim 6659 call map(myDict, {key, val -> key .. '-' .. val}) 6660 <If you do not use "val" you can leave it out: >vim 6661 call map(myDict, {key -> 'item: ' .. key}) 6662 <If you do not use "key" you can use a short name: >vim 6663 call map(myDict, {_, val -> 'item: ' .. val}) 6664 < 6665 The operation is done in-place for a |List| and |Dictionary|. 6666 If you want it to remain unmodified make a copy first: >vim 6667 let tlist = map(copy(mylist), ' v:val .. "\t"') 6668 6669 <Returns {expr1}, the |List| or |Dictionary| that was filtered, 6670 or a new |Blob| or |String|. 6671 When an error is encountered while evaluating {expr2} no 6672 further items in {expr1} are processed. 6673 When {expr2} is a Funcref errors inside a function are 6674 ignored, unless it was defined with the "abort" flag. 6675 6676 ]=], 6677 name = 'map', 6678 params = { { 'expr1', 'string|table|any[]' }, { 'expr2', 'string|function' } }, 6679 signature = 'map({expr1}, {expr2})', 6680 }, 6681 maparg = { 6682 args = { 1, 4 }, 6683 base = 1, 6684 desc = [=[ 6685 When {dict} is omitted or zero: Return the rhs of mapping 6686 {name} in mode {mode}. The returned String has special 6687 characters translated like in the output of the ":map" command 6688 listing. When {dict} is TRUE a dictionary is returned, see 6689 below. To get a list of all mappings see |maplist()|. 6690 6691 When there is no mapping for {name}, an empty String is 6692 returned if {dict} is FALSE, otherwise returns an empty Dict. 6693 When the mapping for {name} is empty, then "<Nop>" is 6694 returned. 6695 6696 The {name} can have special key names, like in the ":map" 6697 command. 6698 6699 {mode} can be one of these strings: 6700 "n" Normal 6701 "v" Visual (including Select) 6702 "o" Operator-pending 6703 "i" Insert 6704 "c" Cmd-line 6705 "s" Select 6706 "x" Visual 6707 "l" langmap |language-mapping| 6708 "t" Terminal 6709 "" Normal, Visual and Operator-pending 6710 When {mode} is omitted, the modes for "" are used. 6711 6712 When {abbr} is there and it is |TRUE| use abbreviations 6713 instead of mappings. 6714 6715 When {dict} is |TRUE|, return a dictionary describing the 6716 mapping, with these items: *mapping-dict* 6717 "lhs" The {lhs} of the mapping as it would be typed 6718 "lhsraw" The {lhs} of the mapping as raw bytes 6719 "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate 6720 form, only present when it differs from "lhsraw" 6721 "rhs" The {rhs} of the mapping as typed. 6722 "callback" Lua function, if RHS was defined as such. 6723 "silent" 1 for a |:map-silent| mapping, else 0. 6724 "noremap" 1 if the {rhs} of the mapping is not remappable. 6725 "script" 1 if mapping was defined with <script>. 6726 "expr" 1 for an expression mapping (|:map-<expr>|). 6727 "buffer" 1 for a buffer local mapping (|:map-local|). 6728 "mode" Modes for which the mapping is defined. In 6729 addition to the modes mentioned above, these 6730 characters will be used: 6731 " " Normal, Visual and Operator-pending 6732 "!" Insert and Commandline mode 6733 (|mapmode-ic|) 6734 "sid" The script local ID, used for <sid> mappings 6735 (|<SID>|). Negative for special contexts. 6736 "scriptversion" The version of the script, always 1. 6737 "lnum" The line number in "sid", zero if unknown. 6738 "nowait" Do not wait for other, longer mappings. 6739 (|:map-<nowait>|). 6740 "abbr" True if this is an |abbreviation|. 6741 "mode_bits" Nvim's internal binary representation of "mode". 6742 |mapset()| ignores this; only "mode" is used. 6743 See |maplist()| for usage examples. The values 6744 are from src/nvim/state_defs.h and may change in 6745 the future. 6746 6747 The dictionary can be used to restore a mapping with 6748 |mapset()|. 6749 6750 The mappings local to the current buffer are checked first, 6751 then the global mappings. 6752 This function can be used to map a key even when it's already 6753 mapped, and have it do the original mapping too. Sketch: >vim 6754 exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n') 6755 < 6756 6757 ]=], 6758 name = 'maparg', 6759 params = { 6760 { 'name', 'string' }, 6761 { 'mode', 'string' }, 6762 { 'abbr', 'boolean' }, 6763 { 'dict', 'false' }, 6764 }, 6765 signature = 'maparg({name} [, {mode} [, {abbr} [, {dict}]]])', 6766 returns = 'string', 6767 }, 6768 maparg__1 = { 6769 args = { 4 }, 6770 base = 1, 6771 name = 'maparg', 6772 params = { 6773 { 'name', 'string' }, 6774 { 'mode', 'string' }, 6775 { 'abbr', 'boolean' }, 6776 { 'dict', 'true' }, 6777 }, 6778 returns = 'table<string,any>', 6779 }, 6780 mapcheck = { 6781 args = { 1, 3 }, 6782 base = 1, 6783 desc = [=[ 6784 Check if there is a mapping that matches with {name} in mode 6785 {mode}. See |maparg()| for {mode} and special names in 6786 {name}. 6787 When {abbr} is there and it is non-zero use abbreviations 6788 instead of mappings. 6789 A match happens with a mapping that starts with {name} and 6790 with a mapping which is equal to the start of {name}. 6791 6792 matches mapping "a" "ab" "abc" ~ 6793 mapcheck("a") yes yes yes 6794 mapcheck("abc") yes yes yes 6795 mapcheck("ax") yes no no 6796 mapcheck("b") no no no 6797 6798 The difference with |maparg()| is that mapcheck() finds a 6799 mapping that matches with {name}, while |maparg()| only finds a 6800 mapping for {name} exactly. 6801 When there is no mapping that starts with {name}, an empty 6802 String is returned. If there is one, the RHS of that mapping 6803 is returned. If there are several mappings that start with 6804 {name}, the RHS of one of them is returned. This will be 6805 "<Nop>" if the RHS is empty. 6806 The mappings local to the current buffer are checked first, 6807 then the global mappings. 6808 This function can be used to check if a mapping can be added 6809 without being ambiguous. Example: >vim 6810 if mapcheck("_vv") == "" 6811 map _vv :set guifont=7x13<CR> 6812 endif 6813 <This avoids adding the "_vv" mapping when there already is a 6814 mapping for "_v" or for "_vvv". 6815 6816 ]=], 6817 name = 'mapcheck', 6818 params = { { 'name', 'string' }, { 'mode', 'string' }, { 'abbr', 'boolean' } }, 6819 signature = 'mapcheck({name} [, {mode} [, {abbr}]])', 6820 }, 6821 maplist = { 6822 args = { 0, 1 }, 6823 desc = [[ 6824 Returns a |List| of all mappings. Each List item is a |Dict|, 6825 the same as what is returned by |maparg()|, see 6826 |mapping-dict|. When {abbr} is there and it is |TRUE| use 6827 abbreviations instead of mappings. 6828 6829 Example to show all mappings with "MultiMatch" in rhs: >vim 6830 echo maplist()->filter({_, m -> 6831 \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0 6832 \ }) 6833 <It can be tricky to find mappings for particular |:map-modes|. 6834 |mapping-dict|'s "mode_bits" can simplify this. For example, 6835 the mode_bits for Normal, Insert or Command-line modes are 6836 0x19. To find all the mappings available in those modes you 6837 can do: >vim 6838 let saved_maps = [] 6839 for m in maplist() 6840 if and(m.mode_bits, 0x19) != 0 6841 eval saved_maps->add(m) 6842 endif 6843 endfor 6844 echo saved_maps->mapnew({_, m -> m.lhs}) 6845 <The values of the mode_bits are defined in Nvim's 6846 src/nvim/state_defs.h file and they can be discovered at 6847 runtime using |:map-commands| and "maplist()". Example: >vim 6848 omap xyzzy <Nop> 6849 let op_bit = maplist()->filter( 6850 \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits 6851 ounmap xyzzy 6852 echo printf("Operator-pending mode bit: 0x%x", op_bit) 6853 < 6854 ]], 6855 name = 'maplist', 6856 params = { { 'abbr', '0|1' } }, 6857 returns = 'table[]', 6858 signature = 'maplist([{abbr}])', 6859 }, 6860 mapnew = { 6861 args = 2, 6862 base = 1, 6863 desc = [=[ 6864 Like |map()| but instead of replacing items in {expr1} a new 6865 List or Dictionary is created and returned. {expr1} remains 6866 unchanged. Items can still be changed by {expr2}, if you 6867 don't want that use |deepcopy()| first. 6868 ]=], 6869 name = 'mapnew', 6870 params = { { 'expr1', 'any' }, { 'expr2', 'any' } }, 6871 signature = 'mapnew({expr1}, {expr2})', 6872 }, 6873 mapset = { 6874 args = { 1, 3 }, 6875 base = 1, 6876 name = 'mapset', 6877 params = { { 'mode', 'string' }, { 'abbr', 'boolean' }, { 'dict', 'table<string,any>' } }, 6878 signature = 'mapset({mode}, {abbr}, {dict})', 6879 }, 6880 mapset__1 = { 6881 args = { 1, 3 }, 6882 base = 1, 6883 desc = [=[ 6884 Restore a mapping from a dictionary, possibly returned by 6885 |maparg()| or |maplist()|. A buffer mapping, when dict.buffer 6886 is true, is set on the current buffer; it is up to the caller 6887 to ensure that the intended buffer is the current buffer. 6888 This feature allows copying mappings from one buffer to 6889 another. 6890 The dict.mode value may restore a single mapping that covers 6891 more than one mode, like with mode values of '!', ' ', "nox", 6892 or 'v'. *E1276* 6893 6894 In the first form, {mode} and {abbr} should be the same as 6895 for the call to |maparg()|. *E460* 6896 {mode} is used to define the mode in which the mapping is set, 6897 not the "mode" entry in {dict}. 6898 Example for saving and restoring a mapping: >vim 6899 let save_map = maparg('K', 'n', 0, 1) 6900 nnoremap K somethingelse 6901 " ... 6902 call mapset('n', 0, save_map) 6903 <Note that if you are going to replace a map in several modes, 6904 e.g. with `:map!`, you need to save/restore the mapping for 6905 all of them, when they might differ. 6906 6907 In the second form, with {dict} as the only argument, mode 6908 and abbr are taken from the dict. 6909 Example: >vim 6910 let save_maps = maplist()->filter( 6911 \ {_, m -> m.lhs == 'K'}) 6912 nnoremap K somethingelse 6913 cnoremap K somethingelse2 6914 " ... 6915 unmap K 6916 for d in save_maps 6917 call mapset(d) 6918 endfor 6919 < 6920 ]=], 6921 name = 'mapset', 6922 params = { { 'dict', 'table<string,any>' } }, 6923 signature = 'mapset({dict})', 6924 }, 6925 match = { 6926 args = { 2, 4 }, 6927 base = 1, 6928 desc = [=[ 6929 When {expr} is a |List| then this returns the index of the 6930 first item where {pat} matches. Each item is used as a 6931 String, |Lists| and |Dictionaries| are used as echoed. 6932 6933 Otherwise, {expr} is used as a String. The result is a 6934 Number, which gives the index (byte offset) in {expr} where 6935 {pat} matches. 6936 6937 A match at the first character or |List| item returns zero. 6938 If there is no match -1 is returned. 6939 6940 For getting submatches see |matchlist()|. 6941 Example: >vim 6942 echo match("testing", "ing") " results in 4 6943 echo match([1, 'x'], '\a') " results in 1 6944 <See |string-match| for how {pat} is used. 6945 *strpbrk()* 6946 Vim doesn't have a strpbrk() function. But you can do: >vim 6947 let sepidx = match(line, '[.,;: \t]') 6948 < *strcasestr()* 6949 Vim doesn't have a strcasestr() function. But you can add 6950 "\c" to the pattern to ignore case: >vim 6951 let idx = match(haystack, '\cneedle') 6952 < 6953 If {start} is given, the search starts from byte index 6954 {start} in a String or item {start} in a |List|. 6955 The result, however, is still the index counted from the 6956 first character/item. Example: >vim 6957 echo match("testing", "ing", 2) 6958 <result is again "4". >vim 6959 echo match("testing", "ing", 4) 6960 <result is again "4". >vim 6961 echo match("testing", "t", 2) 6962 <result is "3". 6963 For a String, if {start} > 0 then it is like the string starts 6964 {start} bytes later, thus "^" will match at {start}. Except 6965 when {count} is given, then it's like matches before the 6966 {start} byte are ignored (this is a bit complicated to keep it 6967 backwards compatible). 6968 For a String, if {start} < 0, it will be set to 0. For a list 6969 the index is counted from the end. 6970 If {start} is out of range ({start} > strlen({expr}) for a 6971 String or {start} > len({expr}) for a |List|) -1 is returned. 6972 6973 When {count} is given use the {count}th match. When a match 6974 is found in a String the search for the next one starts one 6975 character further. Thus this example results in 1: >vim 6976 echo match("testing", "..", 0, 2) 6977 <In a |List| the search continues in the next item. 6978 Note that when {count} is added the way {start} works changes, 6979 see above. 6980 6981 *match-pattern* 6982 See |pattern| for the patterns that are accepted. 6983 The 'ignorecase' option is used to set the ignore-caseness of 6984 the pattern. 'smartcase' is NOT used. The matching is always 6985 done like 'magic' is set and 'cpoptions' is empty. 6986 Note that a match at the start is preferred, thus when the 6987 pattern is using "*" (any number of matches) it tends to find 6988 zero matches at the start instead of a number of matches 6989 further down in the text. 6990 6991 ]=], 6992 name = 'match', 6993 params = { 6994 { 'expr', 'string|any[]' }, 6995 { 'pat', 'string' }, 6996 { 'start', 'integer' }, 6997 { 'count', 'integer' }, 6998 }, 6999 signature = 'match({expr}, {pat} [, {start} [, {count}]])', 7000 returns = 'integer', 7001 }, 7002 matchadd = { 7003 args = { 2, 5 }, 7004 base = 1, 7005 desc = [=[ 7006 Defines a pattern to be highlighted in the current window (a 7007 "match"). It will be highlighted with {group}. Returns an 7008 identification number (ID), which can be used to delete the 7009 match using |matchdelete()|. The ID is bound to the window. 7010 Matching is case sensitive and magic, unless case sensitivity 7011 or magicness are explicitly overridden in {pattern}. The 7012 'magic', 'smartcase' and 'ignorecase' options are not used. 7013 The "Conceal" value is special, it causes the match to be 7014 concealed. 7015 7016 The optional {priority} argument assigns a priority to the 7017 match. A match with a high priority will have its 7018 highlighting overrule that of a match with a lower priority. 7019 A priority is specified as an integer (negative numbers are no 7020 exception). If the {priority} argument is not specified, the 7021 default priority is 10. The priority of 'hlsearch' is zero, 7022 hence all matches with a priority greater than zero will 7023 overrule it. Syntax highlighting (see 'syntax') is a separate 7024 mechanism, and regardless of the chosen priority a match will 7025 always overrule syntax highlighting. 7026 7027 The optional {id} argument allows the request for a specific 7028 match ID. If a specified ID is already taken, an error 7029 message will appear and the match will not be added. An ID 7030 is specified as a positive integer (zero excluded). IDs 1, 2 7031 and 3 are reserved for |:match|, |:2match| and |:3match|, 7032 respectively. 3 is reserved for use by the |matchparen| 7033 plugin. 7034 If the {id} argument is not specified or -1, |matchadd()| 7035 automatically chooses a free ID, which is at least 1000. 7036 7037 The optional {dict} argument allows for further custom 7038 values. Currently this is used to specify a match specific 7039 conceal character that will be shown for |hl-Conceal| 7040 highlighted matches. The dict can have the following members: 7041 7042 conceal Special character to show instead of the 7043 match (only for |hl-Conceal| highlighted 7044 matches, see |:syn-cchar|) 7045 window Instead of the current window use the 7046 window with this number or window ID. 7047 7048 The number of matches is not limited, as it is the case with 7049 the |:match| commands. 7050 7051 Returns -1 on error. 7052 7053 Example: >vim 7054 highlight MyGroup ctermbg=green guibg=green 7055 let m = matchadd("MyGroup", "TODO") 7056 <Deletion of the pattern: >vim 7057 call matchdelete(m) 7058 7059 <A list of matches defined by |matchadd()| and |:match| are 7060 available from |getmatches()|. All matches can be deleted in 7061 one operation by |clearmatches()|. 7062 7063 ]=], 7064 name = 'matchadd', 7065 params = { 7066 { 'group', 'integer|string' }, 7067 { 'pattern', 'string' }, 7068 { 'priority', 'integer' }, 7069 { 'id', 'integer' }, 7070 { 'dict', 'table' }, 7071 }, 7072 signature = 'matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])', 7073 tags = { 'E798', 'E799', 'E801', 'E957' }, 7074 returns = 'integer', 7075 }, 7076 matchaddpos = { 7077 args = { 2, 5 }, 7078 base = 1, 7079 desc = [=[ 7080 Same as |matchadd()|, but requires a list of positions {pos} 7081 instead of a pattern. This command is faster than |matchadd()| 7082 because it does not handle regular expressions and it sets 7083 buffer line boundaries to redraw screen. It is supposed to be 7084 used when fast match additions and deletions are required, for 7085 example to highlight matching parentheses. 7086 *E5030* *E5031* 7087 {pos} is a list of positions. Each position can be one of 7088 these: 7089 - A number. This whole line will be highlighted. The first 7090 line has number 1. 7091 - A list with one number, e.g., [23]. The whole line with 7092 this number will be highlighted. 7093 - A list with two numbers, e.g., [23, 11]. The first number 7094 is the line number, the second one is the column number 7095 (first column is 1, the value must correspond to the byte 7096 index as |col()| would return). The character at this 7097 position will be highlighted. 7098 - A list with three numbers, e.g., [23, 11, 3]. As above, but 7099 the third number gives the length of the highlight in bytes. 7100 7101 Entries with zero and negative line numbers are silently 7102 ignored, as well as entries with negative column numbers and 7103 lengths. 7104 7105 Returns -1 on error. 7106 7107 Example: >vim 7108 highlight MyGroup ctermbg=green guibg=green 7109 let m = matchaddpos("MyGroup", [[23, 24], 34]) 7110 <Deletion of the pattern: >vim 7111 call matchdelete(m) 7112 7113 <Matches added by |matchaddpos()| are returned by 7114 |getmatches()|. 7115 7116 ]=], 7117 name = 'matchaddpos', 7118 params = { 7119 { 'group', 'integer|string' }, 7120 { 'pos', 'any[]' }, 7121 { 'priority', 'integer' }, 7122 { 'id', 'integer' }, 7123 { 'dict', 'table' }, 7124 }, 7125 signature = 'matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])', 7126 returns = 'integer|table', 7127 }, 7128 matcharg = { 7129 args = 1, 7130 base = 1, 7131 desc = [=[ 7132 Selects the {nr} match item, as set with a |:match|, 7133 |:2match| or |:3match| command. 7134 Return a |List| with two elements: 7135 The name of the highlight group used 7136 The pattern used. 7137 When {nr} is not 1, 2 or 3 returns an empty |List|. 7138 When there is no match item set returns ['', '']. 7139 This is useful to save and restore a |:match|. 7140 Highlighting matches using the |:match| commands are limited 7141 to three matches. |matchadd()| does not have this limitation. 7142 7143 ]=], 7144 name = 'matcharg', 7145 params = { { 'nr', 'integer' } }, 7146 signature = 'matcharg({nr})', 7147 returns = 'string[]', 7148 }, 7149 matchbufline = { 7150 args = { 4, 5 }, 7151 base = 1, 7152 desc = [=[ 7153 Returns the |List| of matches in lines from {lnum} to {end} in 7154 buffer {buf} where {pat} matches. 7155 7156 {lnum} and {end} can either be a line number or the string "$" 7157 to refer to the last line in {buf}. 7158 7159 The {dict} argument supports following items: 7160 submatches include submatch information (|/\(|) 7161 7162 For each match, a |Dict| with the following items is returned: 7163 byteidx starting byte index of the match 7164 lnum line number where there is a match 7165 text matched string 7166 Note that there can be multiple matches in a single line. 7167 7168 This function works only for loaded buffers. First call 7169 |bufload()| if needed. 7170 7171 See |match-pattern| for information about the effect of some 7172 option settings on the pattern. 7173 7174 When {buf} is not a valid buffer, the buffer is not loaded or 7175 {lnum} or {end} is not valid then an error is given and an 7176 empty |List| is returned. 7177 7178 Examples: >vim 7179 " Assuming line 3 in buffer 5 contains "a" 7180 echo matchbufline(5, '\<\k\+\>', 3, 3) 7181 < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim 7182 " Assuming line 4 in buffer 10 contains "tik tok" 7183 echo matchbufline(10, '\<\k\+\>', 1, 4) 7184 < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]` 7185 7186 If {submatch} is present and is v:true, then submatches like 7187 "\1", "\2", etc. are also returned. Example: >vim 7188 " Assuming line 2 in buffer 2 contains "acd" 7189 echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2 7190 \ {'submatches': v:true}) 7191 < `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]` 7192 The "submatches" List always contains 9 items. If a submatch 7193 is not found, then an empty string is returned for that 7194 submatch. 7195 ]=], 7196 name = 'matchbufline', 7197 params = { 7198 { 'buf', 'string|integer' }, 7199 { 'pat', 'string' }, 7200 { 'lnum', 'string|integer' }, 7201 { 'end', 'string|integer' }, 7202 { 'dict', 'table' }, 7203 }, 7204 signature = 'matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}])', 7205 returns = 'string[]', 7206 }, 7207 matchdelete = { 7208 args = { 1, 2 }, 7209 base = 1, 7210 desc = [=[ 7211 Deletes a match with ID {id} previously defined by |matchadd()| 7212 or one of the |:match| commands. Returns 0 if successful, 7213 otherwise -1. See example for |matchadd()|. All matches can 7214 be deleted in one operation by |clearmatches()|. 7215 If {win} is specified, use the window with this number or 7216 window ID instead of the current window. 7217 7218 ]=], 7219 name = 'matchdelete', 7220 params = { { 'id', 'integer' }, { 'win', 'integer' } }, 7221 signature = 'matchdelete({id} [, {win}])', 7222 tags = { 'E802', 'E803' }, 7223 }, 7224 matchend = { 7225 args = { 2, 4 }, 7226 base = 1, 7227 desc = [=[ 7228 Same as |match()|, but return the index of first character 7229 after the match. Example: >vim 7230 echo matchend("testing", "ing") 7231 <results in "7". 7232 *strspn()* *strcspn()* 7233 Vim doesn't have a strspn() or strcspn() function, but you can 7234 do it with matchend(): >vim 7235 let span = matchend(line, '[a-zA-Z]') 7236 let span = matchend(line, '[^a-zA-Z]') 7237 <Except that -1 is returned when there are no matches. 7238 7239 The {start}, if given, has the same meaning as for |match()|. >vim 7240 echo matchend("testing", "ing", 2) 7241 <results in "7". >vim 7242 echo matchend("testing", "ing", 5) 7243 <result is "-1". 7244 When {expr} is a |List| the result is equal to |match()|. 7245 7246 ]=], 7247 name = 'matchend', 7248 params = { 7249 { 'expr', 'any' }, 7250 { 'pat', 'string' }, 7251 { 'start', 'integer' }, 7252 { 'count', 'integer' }, 7253 }, 7254 signature = 'matchend({expr}, {pat} [, {start} [, {count}]])', 7255 returns = 'integer', 7256 }, 7257 matchfuzzy = { 7258 args = { 2, 3 }, 7259 base = 1, 7260 desc = [=[ 7261 If {list} is a list of strings, then returns a |List| with all 7262 the strings in {list} that fuzzy match {str}. The strings in 7263 the returned list are sorted based on the matching score. 7264 7265 The optional {dict} argument always supports the following 7266 items: 7267 matchseq When this item is present return only matches 7268 that contain the characters in {str} in the 7269 given sequence. 7270 limit Maximum number of matches in {list} to be 7271 returned. Zero means no limit. 7272 7273 If {list} is a list of dictionaries, then the optional {dict} 7274 argument supports the following additional items: 7275 key Key of the item which is fuzzy matched against 7276 {str}. The value of this item should be a 7277 string. 7278 text_cb |Funcref| that will be called for every item 7279 in {list} to get the text for fuzzy matching. 7280 This should accept a dictionary item as the 7281 argument and return the text for that item to 7282 use for fuzzy matching. 7283 7284 {str} is treated as a literal string and regular expression 7285 matching is NOT supported. The maximum supported {str} length 7286 is 256. 7287 7288 When {str} has multiple words each separated by white space, 7289 then the list of strings that have all the words is returned. 7290 7291 If there are no matching strings or there is an error, then an 7292 empty list is returned. If length of {str} is greater than 7293 256, then returns an empty list. 7294 7295 When {limit} is given, matchfuzzy() will find up to this 7296 number of matches in {list} and return them in sorted order. 7297 7298 Refer to |fuzzy-matching| for more information about fuzzy 7299 matching strings. 7300 7301 Example: >vim 7302 echo matchfuzzy(["clay", "crow"], "cay") 7303 <results in ["clay"]. >vim 7304 echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl") 7305 <results in a list of buffer names fuzzy matching "ndl". >vim 7306 echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'}) 7307 <results in a list of buffer information dicts with buffer 7308 names fuzzy matching "ndl". >vim 7309 echo getbufinfo()->matchfuzzy("spl", 7310 \ {'text_cb' : {v -> v.name}}) 7311 <results in a list of buffer information dicts with buffer 7312 names fuzzy matching "spl". >vim 7313 echo v:oldfiles->matchfuzzy("test") 7314 <results in a list of file names fuzzy matching "test". >vim 7315 let l = readfile("buffer.c")->matchfuzzy("str") 7316 <results in a list of lines in "buffer.c" fuzzy matching "str". >vim 7317 echo ['one two', 'two one']->matchfuzzy('two one') 7318 <results in `['two one', 'one two']` . >vim 7319 echo ['one two', 'two one']->matchfuzzy('two one', 7320 \ {'matchseq': 1}) 7321 <results in `['two one']`. 7322 ]=], 7323 name = 'matchfuzzy', 7324 params = { { 'list', 'any[]' }, { 'str', 'string' }, { 'dict', 'table' } }, 7325 signature = 'matchfuzzy({list}, {str} [, {dict}])', 7326 returns = 'table', 7327 }, 7328 matchfuzzypos = { 7329 args = { 2, 3 }, 7330 base = 1, 7331 desc = [=[ 7332 Same as |matchfuzzy()|, but returns the list of matched 7333 strings, the list of character positions where characters 7334 in {str} matches and a list of matching scores. You can 7335 use |byteidx()| to convert a character position to a byte 7336 position. 7337 7338 If {str} matches multiple times in a string, then only the 7339 positions for the best match is returned. 7340 7341 If there are no matching strings or there is an error, then a 7342 list with three empty list items is returned. 7343 7344 Example: >vim 7345 echo matchfuzzypos(['testing'], 'tsg') 7346 <results in [["testing"], [[0, 2, 6]], [99]] >vim 7347 echo matchfuzzypos(['clay', 'lacy'], 'la') 7348 <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim 7349 echo [{'text': 'hello', 'id' : 10}] 7350 \ ->matchfuzzypos('ll', {'key' : 'text'}) 7351 <results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]` 7352 ]=], 7353 name = 'matchfuzzypos', 7354 params = { { 'list', 'any[]' }, { 'str', 'string' }, { 'dict', 'table' } }, 7355 signature = 'matchfuzzypos({list}, {str} [, {dict}])', 7356 returns = 'table', 7357 }, 7358 matchlist = { 7359 args = { 2, 4 }, 7360 base = 1, 7361 desc = [=[ 7362 Same as |match()|, but return a |List|. The first item in the 7363 list is the matched string, same as what |matchstr()| would 7364 return. Following items are submatches, like "\1", "\2", etc. 7365 in |:substitute|. When an optional submatch didn't match an 7366 empty string is used. Example: >vim 7367 echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)') 7368 <Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', ''] 7369 When there is no match an empty list is returned. 7370 7371 You can pass in a List, but that is not very useful. 7372 7373 ]=], 7374 name = 'matchlist', 7375 params = { 7376 { 'expr', 'any' }, 7377 { 'pat', 'string' }, 7378 { 'start', 'integer' }, 7379 { 'count', 'integer' }, 7380 }, 7381 signature = 'matchlist({expr}, {pat} [, {start} [, {count}]])', 7382 returns = 'string[]', 7383 }, 7384 matchstr = { 7385 args = { 2, 4 }, 7386 base = 1, 7387 desc = [=[ 7388 Same as |match()|, but return the matched string. Example: >vim 7389 echo matchstr("testing", "ing") 7390 <results in "ing". 7391 When there is no match "" is returned. 7392 The {start}, if given, has the same meaning as for |match()|. >vim 7393 echo matchstr("testing", "ing", 2) 7394 <results in "ing". >vim 7395 echo matchstr("testing", "ing", 5) 7396 <result is "". 7397 When {expr} is a |List| then the matching item is returned. 7398 The type isn't changed, it's not necessarily a String. 7399 7400 ]=], 7401 name = 'matchstr', 7402 params = { 7403 { 'expr', 'any' }, 7404 { 'pat', 'string' }, 7405 { 'start', 'integer' }, 7406 { 'count', 'integer' }, 7407 }, 7408 signature = 'matchstr({expr}, {pat} [, {start} [, {count}]])', 7409 returns = 'string', 7410 }, 7411 matchstrlist = { 7412 args = { 2, 3 }, 7413 base = 1, 7414 desc = [=[ 7415 Returns the |List| of matches in {list} where {pat} matches. 7416 {list} is a |List| of strings. {pat} is matched against each 7417 string in {list}. 7418 7419 The {dict} argument supports following items: 7420 submatches include submatch information (|/\(|) 7421 7422 For each match, a |Dict| with the following items is returned: 7423 byteidx starting byte index of the match. 7424 idx index in {list} of the match. 7425 text matched string 7426 submatches a List of submatches. Present only if 7427 "submatches" is set to v:true in {dict}. 7428 7429 See |match-pattern| for information about the effect of some 7430 option settings on the pattern. 7431 7432 Example: >vim 7433 echo matchstrlist(['tik tok'], '\<\k\+\>') 7434 < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim 7435 echo matchstrlist(['a', 'b'], '\<\k\+\>') 7436 < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]` 7437 7438 If "submatches" is present and is v:true, then submatches like 7439 "\1", "\2", etc. are also returned. Example: >vim 7440 echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 7441 \ #{submatches: v:true}) 7442 < `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]` 7443 The "submatches" List always contains 9 items. If a submatch 7444 is not found, then an empty string is returned for that 7445 submatch. 7446 ]=], 7447 name = 'matchstrlist', 7448 params = { { 'list', 'string[]' }, { 'pat', 'string' }, { 'dict', 'table' } }, 7449 signature = 'matchstrlist({list}, {pat} [, {dict}])', 7450 returns = 'string[]', 7451 }, 7452 matchstrpos = { 7453 args = { 2, 4 }, 7454 base = 1, 7455 desc = [=[ 7456 Same as |matchstr()|, but return the matched string, the start 7457 position and the end position of the match. Example: >vim 7458 echo matchstrpos("testing", "ing") 7459 <results in ["ing", 4, 7]. 7460 When there is no match ["", -1, -1] is returned. 7461 The {start}, if given, has the same meaning as for |match()|. >vim 7462 echo matchstrpos("testing", "ing", 2) 7463 <results in ["ing", 4, 7]. >vim 7464 echo matchstrpos("testing", "ing", 5) 7465 <result is ["", -1, -1]. 7466 When {expr} is a |List| then the matching item, the index 7467 of first item where {pat} matches, the start position and the 7468 end position of the match are returned. >vim 7469 echo matchstrpos([1, '__x'], '\a') 7470 <result is ["x", 1, 2, 3]. 7471 The type isn't changed, it's not necessarily a String. 7472 7473 ]=], 7474 name = 'matchstrpos', 7475 params = { 7476 { 'expr', 'any' }, 7477 { 'pat', 'string' }, 7478 { 'start', 'integer' }, 7479 { 'count', 'integer' }, 7480 }, 7481 signature = 'matchstrpos({expr}, {pat} [, {start} [, {count}]])', 7482 returns = 'table', 7483 }, 7484 max = { 7485 args = 1, 7486 base = 1, 7487 desc = [=[ 7488 Return the maximum value of all items in {expr}. Example: >vim 7489 echo max([apples, pears, oranges]) 7490 7491 <{expr} can be a |List| or a |Dictionary|. For a Dictionary, 7492 it returns the maximum of all values in the Dictionary. 7493 If {expr} is neither a List nor a Dictionary, or one of the 7494 items in {expr} cannot be used as a Number this results in 7495 an error. An empty |List| or |Dictionary| results in zero. 7496 7497 ]=], 7498 name = 'max', 7499 params = { { 'expr', 'any' } }, 7500 returns = 'number', 7501 signature = 'max({expr})', 7502 }, 7503 menu_get = { 7504 args = { 1, 2 }, 7505 desc = [=[ 7506 Returns a |List| of |Dictionaries| describing |menus| (defined 7507 by |:menu|, |:amenu|, …), including |hidden-menus|. 7508 7509 {path} matches a menu by name, or all menus if {path} is an 7510 empty string. Example: >vim 7511 echo menu_get('File','') 7512 echo menu_get('') 7513 < 7514 {modes} is a string of zero or more modes (see |maparg()| or 7515 |creating-menus| for the list of modes). "a" means "all". 7516 7517 Example: >vim 7518 nnoremenu &Test.Test inormal 7519 inoremenu Test.Test insert 7520 vnoremenu Test.Test x 7521 echo menu_get("") 7522 7523 <returns something like this: > 7524 7525 [ { 7526 "hidden": 0, 7527 "name": "Test", 7528 "priority": 500, 7529 "shortcut": 84, 7530 "submenus": [ { 7531 "hidden": 0, 7532 "mappings": { 7533 i": { 7534 "enabled": 1, 7535 "noremap": 1, 7536 "rhs": "insert", 7537 "sid": 1, 7538 "silent": 0 7539 }, 7540 n": { ... }, 7541 s": { ... }, 7542 v": { ... } 7543 }, 7544 "name": "Test", 7545 "priority": 500, 7546 "shortcut": 0 7547 } ] 7548 } ] 7549 < 7550 ]=], 7551 name = 'menu_get', 7552 params = { { 'path', 'string' }, { 'modes', 'string' } }, 7553 signature = 'menu_get({path} [, {modes}])', 7554 }, 7555 menu_info = { 7556 args = { 1, 2 }, 7557 base = 1, 7558 desc = [=[ 7559 Return information about the specified menu {name} in 7560 mode {mode}. The menu name should be specified without the 7561 shortcut character ('&'). If {name} is "", then the top-level 7562 menu names are returned. 7563 7564 {mode} can be one of these strings: 7565 "n" Normal 7566 "v" Visual (including Select) 7567 "o" Operator-pending 7568 "i" Insert 7569 "c" Cmd-line 7570 "s" Select 7571 "x" Visual 7572 "t" Terminal-Job 7573 "" Normal, Visual and Operator-pending 7574 "!" Insert and Cmd-line 7575 When {mode} is omitted, the modes for "" are used. 7576 7577 Returns a |Dictionary| containing the following items: 7578 accel menu item accelerator text |menu-text| 7579 display display name (name without '&') 7580 enabled v:true if this menu item is enabled 7581 Refer to |:menu-enable| 7582 icon name of the icon file (for toolbar) 7583 |toolbar-icon| 7584 iconidx index of a built-in icon 7585 modes modes for which the menu is defined. In 7586 addition to the modes mentioned above, these 7587 characters will be used: 7588 " " Normal, Visual and Operator-pending 7589 name menu item name. 7590 noremenu v:true if the {rhs} of the menu item is not 7591 remappable else v:false. 7592 priority menu order priority |menu-priority| 7593 rhs right-hand-side of the menu item. The 7594 returned string has special characters 7595 translated like in the output of the ":menu" 7596 command listing. When the {rhs} of a menu 7597 item is empty, then "<Nop>" is returned. 7598 script v:true if script-local remapping of {rhs} is 7599 allowed else v:false. See |:menu-script|. 7600 shortcut shortcut key (character after '&' in 7601 the menu name) |menu-shortcut| 7602 silent v:true if the menu item is created 7603 with <silent> argument |:menu-silent| 7604 submenus |List| containing the names of 7605 all the submenus. Present only if the menu 7606 item has submenus. 7607 7608 Returns an empty dictionary if the menu item is not found. 7609 7610 Examples: >vim 7611 echo menu_info('Edit.Cut') 7612 echo menu_info('File.Save', 'n') 7613 7614 " Display the entire menu hierarchy in a buffer 7615 func ShowMenu(name, pfx) 7616 let m = menu_info(a:name) 7617 call append(line('$'), a:pfx .. m.display) 7618 for child in m->get('submenus', []) 7619 call ShowMenu(a:name .. '.' .. escape(child, '.'), 7620 \ a:pfx .. ' ') 7621 endfor 7622 endfunc 7623 new 7624 for topmenu in menu_info('').submenus 7625 call ShowMenu(topmenu, '') 7626 endfor 7627 < 7628 ]=], 7629 name = 'menu_info', 7630 params = { { 'name', 'string' }, { 'mode', 'string' } }, 7631 signature = 'menu_info({name} [, {mode}])', 7632 }, 7633 min = { 7634 args = 1, 7635 base = 1, 7636 desc = [=[ 7637 Return the minimum value of all items in {expr}. Example: >vim 7638 echo min([apples, pears, oranges]) 7639 7640 <{expr} can be a |List| or a |Dictionary|. For a Dictionary, 7641 it returns the minimum of all values in the Dictionary. 7642 If {expr} is neither a List nor a Dictionary, or one of the 7643 items in {expr} cannot be used as a Number this results in 7644 an error. An empty |List| or |Dictionary| results in zero. 7645 7646 ]=], 7647 name = 'min', 7648 params = { { 'expr', 'any' } }, 7649 returns = 'number', 7650 signature = 'min({expr})', 7651 }, 7652 mkdir = { 7653 args = { 1, 3 }, 7654 base = 1, 7655 desc = [=[ 7656 Create directory {name}. 7657 7658 When {flags} is present it must be a string. An empty string 7659 has no effect. 7660 7661 {flags} can contain these character flags: 7662 "p" intermediate directories will be created as necessary 7663 "D" {name} will be deleted at the end of the current 7664 function, but not recursively |:defer| 7665 "R" {name} will be deleted recursively at the end of the 7666 current function |:defer| 7667 7668 Note that when {name} has more than one part and "p" is used 7669 some directories may already exist. Only the first one that 7670 is created and what it contains is scheduled to be deleted. 7671 E.g. when using: >vim 7672 call mkdir('subdir/tmp/autoload', 'pR') 7673 <and "subdir" already exists then "subdir/tmp" will be 7674 scheduled for deletion, like with: >vim 7675 defer delete('subdir/tmp', 'rf') 7676 < 7677 If {prot} is given it is used to set the protection bits of 7678 the new directory. The default is 0o755 (rwxr-xr-x: r/w for 7679 the user, readable for others). Use 0o700 to make it 7680 unreadable for others. This is used for the newly created 7681 directories. Note: umask is applied to {prot} (on Unix). 7682 Example: >vim 7683 call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700) 7684 7685 <This function is not available in the |sandbox|. 7686 7687 If you try to create an existing directory with {flags} set to 7688 "p" mkdir() will silently exit. 7689 7690 The function result is a Number, which is TRUE if the call was 7691 successful or FALSE if the directory creation failed or partly 7692 failed. 7693 7694 ]=], 7695 name = 'mkdir', 7696 params = { { 'name', 'string' }, { 'flags', 'string' }, { 'prot', 'string' } }, 7697 returns = 'integer', 7698 signature = 'mkdir({name} [, {flags} [, {prot}]])', 7699 tags = { 'E739' }, 7700 }, 7701 mode = { 7702 args = { 0, 1 }, 7703 base = 1, 7704 desc = [=[ 7705 Return a string that indicates the current mode. 7706 If {expr} is supplied and it evaluates to a non-zero Number or 7707 a non-empty String (|non-zero-arg|), then the full mode is 7708 returned, otherwise only the first letter is returned. 7709 Also see |state()|. 7710 7711 n Normal 7712 no Operator-pending 7713 nov Operator-pending (forced charwise |o_v|) 7714 noV Operator-pending (forced linewise |o_V|) 7715 noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|) 7716 CTRL-V is one character 7717 niI Normal using |i_CTRL-O| in |Insert-mode| 7718 niR Normal using |i_CTRL-O| in |Replace-mode| 7719 niV Normal using |i_CTRL-O| in |Virtual-Replace-mode| 7720 nt Normal in |terminal-emulator| (insert goes to 7721 Terminal mode) 7722 ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode| 7723 v Visual by character 7724 vs Visual by character using |v_CTRL-O| in Select mode 7725 V Visual by line 7726 Vs Visual by line using |v_CTRL-O| in Select mode 7727 CTRL-V Visual blockwise 7728 CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode 7729 s Select by character 7730 S Select by line 7731 CTRL-S Select blockwise 7732 i Insert 7733 ic Insert mode completion |compl-generic| 7734 ix Insert mode |i_CTRL-X| completion 7735 R Replace |R| 7736 Rc Replace mode completion |compl-generic| 7737 Rx Replace mode |i_CTRL-X| completion 7738 Rv Virtual Replace |gR| 7739 Rvc Virtual Replace mode completion |compl-generic| 7740 Rvx Virtual Replace mode |i_CTRL-X| completion 7741 c Command-line editing 7742 cr Command-line editing overstrike mode |c_<Insert>| 7743 cv Vim Ex mode |gQ| 7744 cvr Vim Ex mode while in overstrike mode |c_<Insert>| 7745 r Hit-enter prompt 7746 rm The -- more -- prompt 7747 r? A |:confirm| query of some sort 7748 ! Shell or external command is executing 7749 t Terminal mode: keys go to the job 7750 7751 This is useful in the 'statusline' option or RPC calls. In 7752 most other places it always returns "c" or "n". 7753 Note that in the future more modes and more specific modes may 7754 be added. It's better not to compare the whole string but 7755 only the leading character(s). 7756 Also see |visualmode()|. 7757 7758 ]=], 7759 name = 'mode', 7760 params = { { 'expr', 'any' } }, 7761 signature = 'mode([{expr}])', 7762 }, 7763 msgpackdump = { 7764 args = { 1, 2 }, 7765 desc = [=[ 7766 Convert a list of Vimscript objects to msgpack. Returned value is a 7767 |readfile()|-style list. When {type} contains "B", a |Blob| is 7768 returned instead. Example: >vim 7769 call writefile(msgpackdump([{}]), 'fname.mpack', 'b') 7770 <or, using a |Blob|: >vim 7771 call writefile(msgpackdump([{}], 'B'), 'fname.mpack') 7772 < 7773 This will write the single 0x80 byte to a `fname.mpack` file 7774 (dictionary with zero items is represented by 0x80 byte in 7775 messagepack). 7776 7777 Limitations: *E5004* *E5005* 7778 1. |Funcref|s cannot be dumped. 7779 2. Containers that reference themselves cannot be dumped. 7780 3. Dictionary keys are always dumped as STR strings. 7781 4. Other strings and |Blob|s are always dumped as BIN strings. 7782 5. Points 3. and 4. do not apply to |msgpack-special-dict|s. 7783 ]=], 7784 name = 'msgpackdump', 7785 params = { { 'list', 'any' }, { 'type', 'any' } }, 7786 signature = 'msgpackdump({list} [, {type}])', 7787 }, 7788 msgpackparse = { 7789 args = 1, 7790 desc = [=[ 7791 Convert a |readfile()|-style list or a |Blob| to a list of 7792 Vimscript objects. 7793 Example: >vim 7794 let fname = expand('~/.config/nvim/shada/main.shada') 7795 let mpack = readfile(fname, 'b') 7796 let shada_objects = msgpackparse(mpack) 7797 <This will read ~/.config/nvim/shada/main.shada file to 7798 `shada_objects` list. 7799 7800 Limitations: 7801 1. Mapping ordering is not preserved unless messagepack 7802 mapping is dumped using generic mapping 7803 (|msgpack-special-map|). 7804 2. Since the parser aims to preserve all data untouched 7805 (except for 1.) some strings are parsed to 7806 |msgpack-special-dict| format which is not convenient to 7807 use. 7808 *msgpack-special-dict* 7809 Some messagepack strings may be parsed to special 7810 dictionaries. Special dictionaries are dictionaries which 7811 7812 1. Contain exactly two keys: `_TYPE` and `_VAL`. 7813 2. `_TYPE` key is one of the types found in |v:msgpack_types| 7814 variable. 7815 3. Value for `_VAL` has the following format (Key column 7816 contains name of the key from |v:msgpack_types|): 7817 7818 Key Value ~ 7819 nil Zero, ignored when dumping. Not returned by 7820 |msgpackparse()| since |v:null| was introduced. 7821 boolean One or zero. When dumping it is only checked that 7822 value is a |Number|. Not returned by |msgpackparse()| 7823 since |v:true| and |v:false| were introduced. 7824 integer |List| with four numbers: sign (-1 or 1), highest two 7825 bits, number with bits from 62nd to 31st, lowest 31 7826 bits. I.e. to get actual number one will need to use 7827 code like > 7828 _VAL[0] * ((_VAL[1] << 62) 7829 & (_VAL[2] << 31) 7830 & _VAL[3]) 7831 < Special dictionary with this type will appear in 7832 |msgpackparse()| output under one of the following 7833 circumstances: 7834 1. |Number| is 32-bit and value is either above 7835 INT32_MAX or below INT32_MIN. 7836 2. |Number| is 64-bit and value is above INT64_MAX. It 7837 cannot possibly be below INT64_MIN because msgpack 7838 C parser does not support such values. 7839 float |Float|. This value cannot possibly appear in 7840 |msgpackparse()| output. 7841 string |String|, or |Blob| if binary string contains zero 7842 byte. This value cannot appear in |msgpackparse()| 7843 output since blobs were introduced. 7844 array |List|. This value cannot appear in |msgpackparse()| 7845 output. 7846 *msgpack-special-map* 7847 map |List| of |List|s with two items (key and value) each. 7848 This value will appear in |msgpackparse()| output if 7849 parsed mapping contains one of the following keys: 7850 1. Any key that is not a string (including keys which 7851 are binary strings). 7852 2. String with NUL byte inside. 7853 3. Duplicate key. 7854 ext |List| with two values: first is a signed integer 7855 representing extension type. Second is 7856 |readfile()|-style list of strings. 7857 ]=], 7858 name = 'msgpackparse', 7859 params = { { 'data', 'any' } }, 7860 signature = 'msgpackparse({data})', 7861 }, 7862 nextnonblank = { 7863 args = 1, 7864 base = 1, 7865 desc = [=[ 7866 Return the line number of the first line at or below {lnum} 7867 that is not blank. Example: >vim 7868 if getline(nextnonblank(1)) =~ "Java" | endif 7869 <When {lnum} is invalid or there is no non-blank line at or 7870 below it, zero is returned. 7871 {lnum} is used like with |getline()|. 7872 See also |prevnonblank()|. 7873 7874 ]=], 7875 name = 'nextnonblank', 7876 params = { { 'lnum', 'integer|string' } }, 7877 returns = 'integer', 7878 signature = 'nextnonblank({lnum})', 7879 }, 7880 nr2char = { 7881 args = { 1, 2 }, 7882 base = 1, 7883 desc = [=[ 7884 Return a string with a single character, which has the number 7885 value {expr}. Examples: >vim 7886 echo nr2char(64) " returns '@' 7887 echo nr2char(32) " returns ' ' 7888 <Example for "utf-8": >vim 7889 echo nr2char(300) " returns I with bow character 7890 < 7891 UTF-8 encoding is always used, {utf8} option has no effect, 7892 and exists only for backwards-compatibility. 7893 Note that a NUL character in the file is specified with 7894 nr2char(10), because NULs are represented with newline 7895 characters. nr2char(0) is a real NUL and terminates the 7896 string, thus results in an empty string. 7897 7898 ]=], 7899 name = 'nr2char', 7900 params = { { 'expr', 'integer' }, { 'utf8', 'boolean' } }, 7901 returns = 'string', 7902 signature = 'nr2char({expr} [, {utf8}])', 7903 }, 7904 nvim_api__ = { 7905 args = 1, 7906 base = 1, 7907 desc = [=[ 7908 Call nvim |api| functions. The type checking of arguments will 7909 be stricter than for most other builtins. For instance, 7910 if Integer is expected, a |Number| must be passed in, a 7911 |String| will not be autoconverted. 7912 Buffer numbers, as returned by |bufnr()| could be used as 7913 first argument to nvim_buf_... functions. All functions 7914 expecting an object (buffer, window or tabpage) can 7915 also take the numerical value 0 to indicate the current 7916 (focused) object. 7917 ]=], 7918 lua = false, 7919 name = 'nvim_...', 7920 params = VARARGS, 7921 signature = 'nvim_...({...})', 7922 tags = { 'E5555', 'eval-api' }, 7923 }, 7924 ['or'] = { 7925 args = 2, 7926 base = 1, 7927 desc = [=[ 7928 Bitwise OR on the two arguments. The arguments are converted 7929 to a number. A List, Dict or Float argument causes an error. 7930 Also see `and()` and `xor()`. 7931 Example: >vim 7932 let bits = or(bits, 0x80) 7933 7934 <Rationale: The reason this is a function and not using the "|" 7935 character like many languages, is that Vi has always used "|" 7936 to separate commands. In many places it would not be clear if 7937 "|" is an operator or a command separator. 7938 ]=], 7939 name = 'or', 7940 params = { { 'expr', 'number' }, { 'expr', 'number' } }, 7941 signature = 'or({expr}, {expr})', 7942 }, 7943 pathshorten = { 7944 args = { 1, 2 }, 7945 base = 1, 7946 desc = [=[ 7947 Shorten directory names in the path {path} and return the 7948 result. The tail, the file name, is kept as-is. The other 7949 components in the path are reduced to {len} letters in length. 7950 If {len} is omitted or smaller than 1 then 1 is used (single 7951 letters). Leading '~' and '.' characters are kept. Examples: >vim 7952 echo pathshorten('~/.config/nvim/autoload/file1.vim') 7953 < ~/.c/n/a/file1.vim ~ 7954 >vim 7955 echo pathshorten('~/.config/nvim/autoload/file2.vim', 2) 7956 < ~/.co/nv/au/file2.vim ~ 7957 It doesn't matter if the path exists or not. 7958 Returns an empty string on error. 7959 7960 ]=], 7961 name = 'pathshorten', 7962 params = { { 'path', 'string' }, { 'len', 'integer' } }, 7963 returns = 'string', 7964 signature = 'pathshorten({path} [, {len}])', 7965 }, 7966 perleval = { 7967 args = 1, 7968 base = 1, 7969 desc = [=[ 7970 Evaluate |perl| expression {expr} and return its result 7971 converted to Vim data structures. 7972 Numbers and strings are returned as they are (strings are 7973 copied though). 7974 Lists are represented as Vim |List| type. 7975 Dictionaries are represented as Vim |Dictionary| type, 7976 non-string keys result in error. 7977 7978 Note: If you want an array or hash, {expr} must return a 7979 reference to it. 7980 Example: >vim 7981 echo perleval('[1 .. 4]') 7982 < [1, 2, 3, 4] 7983 7984 ]=], 7985 name = 'perleval', 7986 params = { { 'expr', 'any' } }, 7987 signature = 'perleval({expr})', 7988 }, 7989 pow = { 7990 args = 2, 7991 base = 1, 7992 desc = [=[ 7993 Return the power of {x} to the exponent {y} as a |Float|. 7994 {x} and {y} must evaluate to a |Float| or a |Number|. 7995 Returns 0.0 if {x} or {y} is not a |Float| or a |Number|. 7996 Examples: >vim 7997 echo pow(3, 3) 7998 < 27.0 >vim 7999 echo pow(2, 16) 8000 < 65536.0 >vim 8001 echo pow(32, 0.20) 8002 < 2.0 8003 8004 ]=], 8005 name = 'pow', 8006 params = { { 'x', 'number' }, { 'y', 'number' } }, 8007 returns = 'number', 8008 signature = 'pow({x}, {y})', 8009 }, 8010 preinserted = { 8011 desc = [=[ 8012 Returns non-zero if text has been inserted after the cursor 8013 because "preinsert" is present in 'completeopt', or because 8014 "longest" is present in 'completeopt' while 'autocomplete' 8015 is active. Otherwise returns zero. 8016 ]=], 8017 name = 'preinserted', 8018 params = {}, 8019 returns = 'number', 8020 signature = 'preinserted()', 8021 }, 8022 prevnonblank = { 8023 args = 1, 8024 base = 1, 8025 desc = [=[ 8026 Return the line number of the first line at or above {lnum} 8027 that is not blank. Example: >vim 8028 let ind = indent(prevnonblank(v:lnum - 1)) 8029 <When {lnum} is invalid or there is no non-blank line at or 8030 above it, zero is returned. 8031 {lnum} is used like with |getline()|. 8032 Also see |nextnonblank()|. 8033 8034 ]=], 8035 name = 'prevnonblank', 8036 params = { { 'lnum', 'integer|string' } }, 8037 returns = 'integer', 8038 signature = 'prevnonblank({lnum})', 8039 }, 8040 printf = { 8041 args = { 1 }, 8042 base = 2, 8043 desc = [=[ 8044 Return a String with {fmt}, where "%" items are replaced by 8045 the formatted form of their respective arguments. Example: >vim 8046 echo printf("%4d: E%d %.30s", lnum, errno, msg) 8047 <May result in: 8048 " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~ 8049 8050 When used as a |method| the base is passed as the second 8051 argument: >vim 8052 Compute()->printf("result: %d") 8053 < 8054 You can use `call()` to pass the items as a list. 8055 8056 Often used items are: 8057 %s string 8058 %6S string right-aligned in 6 display cells 8059 %6s string right-aligned in 6 bytes 8060 %.9s string truncated to 9 bytes 8061 %c single byte 8062 %d decimal number 8063 %5d decimal number padded with spaces to 5 characters 8064 %b binary number 8065 %08b binary number padded with zeros to at least 8 characters 8066 %B binary number using upper case letters 8067 %x hex number 8068 %04x hex number padded with zeros to at least 4 characters 8069 %X hex number using upper case letters 8070 %o octal number 8071 %f floating point number as 12.23, inf, -inf or nan 8072 %F floating point number as 12.23, INF, -INF or NAN 8073 %e floating point number as 1.23e3, inf, -inf or nan 8074 %E floating point number as 1.23E3, INF, -INF or NAN 8075 %g floating point number, as %f or %e depending on value 8076 %G floating point number, as %F or %E depending on value 8077 %% the % character itself 8078 %p representation of the pointer to the container 8079 8080 Conversion specifications start with '%' and end with the 8081 conversion type. All other characters are copied unchanged to 8082 the result. 8083 8084 The "%" starts a conversion specification. The following 8085 arguments appear in sequence: 8086 8087 % [pos-argument] [flags] [field-width] [.precision] type 8088 8089 pos-argument 8090 At most one positional argument specifier. These take 8091 the form {n$}, where n is >= 1. 8092 8093 flags 8094 Zero or more of the following flags: 8095 8096 # The value should be converted to an "alternate 8097 form". For c, d, and s conversions, this option 8098 has no effect. For o conversions, the precision 8099 of the number is increased to force the first 8100 character of the output string to a zero (except 8101 if a zero value is printed with an explicit 8102 precision of zero). 8103 For x and X conversions, a non-zero result has 8104 the string "0x" (or "0X" for X conversions) 8105 prepended to it. 8106 8107 0 (zero) Zero padding. For all conversions the converted 8108 value is padded on the left with zeros rather 8109 than blanks. If a precision is given with a 8110 numeric conversion (d, o, x, and X), the 0 flag 8111 is ignored. 8112 8113 - A negative field width flag; the converted value 8114 is to be left adjusted on the field boundary. 8115 The converted value is padded on the right with 8116 blanks, rather than on the left with blanks or 8117 zeros. A - overrides a 0 if both are given. 8118 8119 ' ' (space) A blank should be left before a positive 8120 number produced by a signed conversion (d). 8121 8122 + A sign must always be placed before a number 8123 produced by a signed conversion. A + overrides 8124 a space if both are used. 8125 8126 field-width 8127 An optional decimal digit string specifying a minimum 8128 field width. If the converted value has fewer bytes 8129 than the field width, it will be padded with spaces on 8130 the left (or right, if the left-adjustment flag has 8131 been given) to fill out the field width. For the S 8132 conversion the count is in cells. 8133 8134 .precision 8135 An optional precision, in the form of a period '.' 8136 followed by an optional digit string. If the digit 8137 string is omitted, the precision is taken as zero. 8138 This gives the minimum number of digits to appear for 8139 d, o, x, and X conversions, the maximum number of 8140 bytes to be printed from a string for s conversions, 8141 or the maximum number of cells to be printed from a 8142 string for S conversions. 8143 For floating point it is the number of digits after 8144 the decimal point. 8145 8146 type 8147 A character that specifies the type of conversion to 8148 be applied, see below. 8149 8150 A field width or precision, or both, may be indicated by an 8151 asterisk "*" instead of a digit string. In this case, a 8152 Number argument supplies the field width or precision. A 8153 negative field width is treated as a left adjustment flag 8154 followed by a positive field width; a negative precision is 8155 treated as though it were missing. Example: >vim 8156 echo printf("%d: %.*s", nr, width, line) 8157 <This limits the length of the text used from "line" to 8158 "width" bytes. 8159 8160 If the argument to be formatted is specified using a 8161 positional argument specifier, and a '*' is used to indicate 8162 that a number argument is to be used to specify the width or 8163 precision, the argument(s) to be used must also be specified 8164 using a {n$} positional argument specifier. See |printf-$|. 8165 8166 The conversion specifiers and their meanings are: 8167 8168 *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X* 8169 dbBoxX The Number argument is converted to signed decimal (d), 8170 unsigned binary (b and B), unsigned octal (o), or 8171 unsigned hexadecimal (x and X) notation. The letters 8172 "abcdef" are used for x conversions; the letters 8173 "ABCDEF" are used for X conversions. The precision, if 8174 any, gives the minimum number of digits that must 8175 appear; if the converted value requires fewer digits, it 8176 is padded on the left with zeros. In no case does a 8177 non-existent or small field width cause truncation of a 8178 numeric field; if the result of a conversion is wider 8179 than the field width, the field is expanded to contain 8180 the conversion result. 8181 The 'h' modifier indicates the argument is 16 bits. 8182 The 'l' modifier indicates the argument is a long 8183 integer. The size will be 32 bits or 64 bits 8184 depending on your platform. 8185 The "ll" modifier indicates the argument is 64 bits. 8186 The b and B conversion specifiers never take a width 8187 modifier and always assume their argument is a 64 bit 8188 integer. 8189 Generally, these modifiers are not useful. They are 8190 ignored when type is known from the argument. 8191 8192 i alias for d 8193 D alias for ld 8194 U alias for lu 8195 O alias for lo 8196 8197 *printf-c* 8198 c The Number argument is converted to a byte, and the 8199 resulting character is written. 8200 8201 *printf-s* 8202 s The text of the String argument is used. If a 8203 precision is specified, no more bytes than the number 8204 specified are used. 8205 If the argument is not a String type, it is 8206 automatically converted to text with the same format 8207 as ":echo". 8208 *printf-S* 8209 S The text of the String argument is used. If a 8210 precision is specified, no more display cells than the 8211 number specified are used. 8212 8213 *printf-f* *E807* 8214 f F The Float argument is converted into a string of the 8215 form 123.456. The precision specifies the number of 8216 digits after the decimal point. When the precision is 8217 zero the decimal point is omitted. When the precision 8218 is not specified 6 is used. A really big number 8219 (out of range or dividing by zero) results in "inf" 8220 or "-inf" with %f (INF or -INF with %F). 8221 "0.0 / 0.0" results in "nan" with %f (NAN with %F). 8222 Example: >vim 8223 echo printf("%.2f", 12.115) 8224 < 12.12 8225 Note that roundoff depends on the system libraries. 8226 Use |round()| when in doubt. 8227 8228 *printf-e* *printf-E* 8229 e E The Float argument is converted into a string of the 8230 form 1.234e+03 or 1.234E+03 when using 'E'. The 8231 precision specifies the number of digits after the 8232 decimal point, like with 'f'. 8233 8234 *printf-g* *printf-G* 8235 g G The Float argument is converted like with 'f' if the 8236 value is between 0.001 (inclusive) and 10000000.0 8237 (exclusive). Otherwise 'e' is used for 'g' and 'E' 8238 for 'G'. When no precision is specified superfluous 8239 zeroes and '+' signs are removed, except for the zero 8240 immediately after the decimal point. Thus 10000000.0 8241 results in 1.0e7. 8242 8243 *printf-%* 8244 % A '%' is written. No argument is converted. The 8245 complete conversion specification is "%%". 8246 8247 When a Number argument is expected a String argument is also 8248 accepted and automatically converted. 8249 When a Float or String argument is expected a Number argument 8250 is also accepted and automatically converted. 8251 Any other argument type results in an error message. 8252 8253 *E766* *E767* 8254 The number of {exprN} arguments must exactly match the number 8255 of "%" items. If there are not sufficient or too many 8256 arguments an error is given. Up to 18 arguments can be used. 8257 8258 *printf-$* 8259 In certain languages, error and informative messages are 8260 more readable when the order of words is different from the 8261 corresponding message in English. To accommodate translations 8262 having a different word order, positional arguments may be 8263 used to indicate this. For instance: >vim 8264 8265 #, c-format 8266 msgid "%s returning %s" 8267 msgstr "waarde %2$s komt terug van %1$s" 8268 < 8269 In this example, the sentence has its 2 string arguments 8270 reversed in the output. >vim 8271 8272 echo printf( 8273 "In The Netherlands, vim's creator's name is: %1$s %2$s", 8274 "Bram", "Moolenaar") 8275 < In The Netherlands, vim's creator's name is: Bram Moolenaar >vim 8276 8277 echo printf( 8278 "In Belgium, vim's creator's name is: %2$s %1$s", 8279 "Bram", "Moolenaar") 8280 < In Belgium, vim's creator's name is: Moolenaar Bram 8281 8282 Width (and precision) can be specified using the '*' 8283 specifier. In this case, you must specify the field width 8284 position in the argument list. >vim 8285 8286 echo printf("%1$*2$.*3$d", 1, 2, 3) 8287 < 001 >vim 8288 echo printf("%2$*3$.*1$d", 1, 2, 3) 8289 < 2 >vim 8290 echo printf("%3$*1$.*2$d", 1, 2, 3) 8291 < 03 >vim 8292 echo printf("%1$*2$.*3$g", 1.4142, 2, 3) 8293 < 1.414 8294 8295 You can mix specifying the width and/or precision directly 8296 and via positional arguments: >vim 8297 8298 echo printf("%1$4.*2$f", 1.4142135, 6) 8299 < 1.414214 >vim 8300 echo printf("%1$*2$.4f", 1.4142135, 6) 8301 < 1.4142 >vim 8302 echo printf("%1$*2$.*3$f", 1.4142135, 6, 2) 8303 < 1.41 8304 8305 You will get an overflow error |E1510|, when the field-width 8306 or precision will result in a string longer than 1 MB 8307 (1024*1024 = 1048576) chars. 8308 8309 *E1500* 8310 You cannot mix positional and non-positional arguments: >vim 8311 echo printf("%s%1$s", "One", "Two") 8312 " E1500: Cannot mix positional and non-positional arguments: 8313 " %s%1$s 8314 < 8315 *E1501* 8316 You cannot skip a positional argument in a format string: >vim 8317 echo printf("%3$s%1$s", "One", "Two", "Three") 8318 " E1501: format argument 2 unused in $-style format: 8319 " %3$s%1$s 8320 < 8321 *E1502* 8322 You can re-use a [field-width] (or [precision]) argument: >vim 8323 echo printf("%1$d at width %2$d is: %1$0*2$d", 1, 2) 8324 " 1 at width 2 is: 01 8325 < 8326 However, you can't use it as a different type: >vim 8327 echo printf("%1$d at width %2$ld is: %1$0*2$d", 1, 2) 8328 " E1502: Positional argument 2 used as field width reused as 8329 " different type: long int/int 8330 < 8331 *E1503* 8332 When a positional argument is used, but not the correct number 8333 or arguments is given, an error is raised: >vim 8334 echo printf("%1$d at width %2$d is: %1$0*2$.*3$d", 1, 2) 8335 " E1503: Positional argument 3 out of bounds: %1$d at width 8336 " %2$d is: %1$0*2$.*3$d 8337 < 8338 Only the first error is reported: >vim 8339 echo printf("%1$0*2$.*3$d %4$d", 1, 2) 8340 " E1503: Positional argument 3 out of bounds: %1$0*2$.*3$d 8341 " %4$d 8342 < 8343 *E1504* 8344 A positional argument can be used more than once: >vim 8345 echo printf("%1$s %2$s %1$s", "One", "Two") 8346 " One Two One 8347 < 8348 However, you can't use a different type the second time: >vim 8349 echo printf("%1$s %2$s %1$d", "One", "Two") 8350 " E1504: Positional argument 1 type used inconsistently: 8351 " int/string 8352 < 8353 *E1505* 8354 Various other errors that lead to a format string being 8355 wrongly formatted lead to: >vim 8356 echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2) 8357 " E1505: Invalid format specifier: %1$d at width %2$d is: 8358 " %01$*2$.3$d 8359 < 8360 *E1507* 8361 This internal error indicates that the logic to parse a 8362 positional format argument ran into a problem that couldn't be 8363 otherwise reported. Please file a bug against Vim if you run 8364 into this, copying the exact format string and parameters that 8365 were used. 8366 8367 ]=], 8368 name = 'printf', 8369 params = { { 'fmt', 'string' }, { 'expr1', 'any' } }, 8370 signature = 'printf({fmt}, {expr1} ...)', 8371 returns = 'string', 8372 }, 8373 prompt_getinput = { 8374 args = 1, 8375 base = 1, 8376 desc = [=[ 8377 Gets the current user-input in |prompt-buffer| {buf} without invoking 8378 prompt_callback. {buf} can be a buffer name or number. 8379 8380 If the buffer doesn't exist or isn't a prompt buffer, an empty 8381 string is returned. 8382 8383 ]=], 8384 name = 'prompt_getinput', 8385 params = { { 'buf', 'integer|string' } }, 8386 signature = 'prompt_getinput({buf})', 8387 }, 8388 prompt_getprompt = { 8389 args = 1, 8390 base = 1, 8391 desc = [=[ 8392 Returns the effective prompt text for buffer {buf}. {buf} can 8393 be a buffer name or number. See |prompt-buffer|. 8394 8395 If the buffer doesn't exist or isn't a prompt buffer, an empty 8396 string is returned. 8397 8398 ]=], 8399 name = 'prompt_getprompt', 8400 params = { { 'buf', 'integer|string' } }, 8401 signature = 'prompt_getprompt({buf})', 8402 }, 8403 prompt_setcallback = { 8404 args = { 2, 2 }, 8405 base = 1, 8406 desc = [=[ 8407 Set prompt callback for buffer {buf} to {expr}. When {expr} 8408 is an empty string the callback is removed. This has only 8409 effect if {buf} has 'buftype' set to "prompt". 8410 8411 The callback is invoked when pressing Enter. The current 8412 buffer will always be the prompt buffer. A new line for a 8413 prompt is added before invoking the callback, thus the prompt 8414 for which the callback was invoked will be in the last but one 8415 line. 8416 If the callback wants to add text to the buffer, it must 8417 insert it above the last line, since that is where the current 8418 prompt is. This can also be done asynchronously. 8419 The callback is invoked with one argument, which is the text 8420 that was entered at the prompt. This can be an empty string 8421 if the user only typed Enter. 8422 Example: >vim 8423 func s:TextEntered(text) 8424 if a:text == 'exit' || a:text == 'quit' 8425 stopinsert 8426 " Reset 'modified' to allow the buffer to be closed. 8427 " We assume there is nothing useful to be saved. 8428 set nomodified 8429 close 8430 else 8431 " Do something useful with "a:text". In this example 8432 " we just repeat it. 8433 call append(line('$') - 1, 'Entered: "' .. a:text .. '"') 8434 endif 8435 endfunc 8436 call prompt_setcallback(bufnr(), function('s:TextEntered')) 8437 < 8438 ]=], 8439 name = 'prompt_setcallback', 8440 params = { { 'buf', 'integer|string' }, { 'expr', 'string|function' } }, 8441 signature = 'prompt_setcallback({buf}, {expr})', 8442 }, 8443 prompt_setinterrupt = { 8444 args = { 2, 2 }, 8445 base = 1, 8446 desc = [=[ 8447 Set a callback for buffer {buf} to {expr}. When {expr} is an 8448 empty string the callback is removed. This has only effect if 8449 {buf} has 'buftype' set to "prompt". 8450 8451 This callback will be invoked when pressing CTRL-C in Insert 8452 mode. Without setting a callback Vim will exit Insert mode, 8453 as in any buffer. 8454 8455 ]=], 8456 name = 'prompt_setinterrupt', 8457 params = { { 'buf', 'integer|string' }, { 'expr', 'string|function' } }, 8458 signature = 'prompt_setinterrupt({buf}, {expr})', 8459 }, 8460 prompt_setprompt = { 8461 args = { 2, 2 }, 8462 base = 1, 8463 desc = [=[ 8464 Set prompt for buffer {buf} to {text}. You most likely want 8465 {text} to end in a space. 8466 The result is only visible if {buf} has 'buftype' set to 8467 "prompt". Example: >vim 8468 call prompt_setprompt(bufnr(''), 'command: ') 8469 < 8470 ]=], 8471 name = 'prompt_setprompt', 8472 params = { { 'buf', 'integer|string' }, { 'text', 'string' } }, 8473 signature = 'prompt_setprompt({buf}, {text})', 8474 }, 8475 pum_getpos = { 8476 desc = [=[ 8477 If the popup menu (see |ins-completion-menu|) is not visible, 8478 returns an empty |Dictionary|, otherwise, returns a 8479 |Dictionary| with the following keys: 8480 height nr of items visible 8481 width screen cells 8482 row top screen row (0 first row) 8483 col leftmost screen column (0 first col) 8484 size total nr of items 8485 scrollbar |TRUE| if scrollbar is visible 8486 8487 The values are the same as in |v:event| during |CompleteChanged|. 8488 ]=], 8489 name = 'pum_getpos', 8490 params = {}, 8491 signature = 'pum_getpos()', 8492 }, 8493 pumvisible = { 8494 desc = [=[ 8495 Returns non-zero when the popup menu is visible, zero 8496 otherwise. See |ins-completion-menu|. 8497 This can be used to avoid some things that would remove the 8498 popup menu. 8499 ]=], 8500 name = 'pumvisible', 8501 params = {}, 8502 signature = 'pumvisible()', 8503 }, 8504 py3eval = { 8505 args = 1, 8506 base = 1, 8507 desc = [=[ 8508 Evaluate Python expression {expr} and return its result 8509 converted to Vim data structures. 8510 Numbers and strings are returned as they are (strings are 8511 copied though, Unicode strings are additionally converted to 8512 UTF-8). 8513 Lists are represented as Vim |List| type. 8514 Dictionaries are represented as Vim |Dictionary| type with 8515 keys converted to strings. 8516 8517 ]=], 8518 name = 'py3eval', 8519 params = { { 'expr', 'any' } }, 8520 signature = 'py3eval({expr})', 8521 }, 8522 pyeval = { 8523 args = 1, 8524 base = 1, 8525 desc = [=[ 8526 Evaluate Python expression {expr} and return its result 8527 converted to Vim data structures. 8528 Numbers and strings are returned as they are (strings are 8529 copied though). 8530 Lists are represented as Vim |List| type. 8531 Dictionaries are represented as Vim |Dictionary| type, 8532 non-string keys result in error. 8533 8534 ]=], 8535 func = 'f_py3eval', 8536 name = 'pyeval', 8537 params = { { 'expr', 'any' } }, 8538 signature = 'pyeval({expr})', 8539 tags = { 'E858', 'E859' }, 8540 }, 8541 pyxeval = { 8542 args = 1, 8543 base = 1, 8544 desc = [=[ 8545 Evaluate Python expression {expr} and return its result 8546 converted to Vim data structures. 8547 Uses Python 2 or 3, see |python_x| and 'pyxversion'. 8548 See also: |pyeval()|, |py3eval()| 8549 8550 ]=], 8551 func = 'f_py3eval', 8552 name = 'pyxeval', 8553 params = { { 'expr', 'any' } }, 8554 signature = 'pyxeval({expr})', 8555 }, 8556 rand = { 8557 args = { 0, 1 }, 8558 base = 1, 8559 desc = [=[ 8560 Return a pseudo-random Number generated with an xoshiro128** 8561 algorithm using seed {expr}. The returned number is 32 bits, 8562 also on 64 bits systems, for consistency. 8563 {expr} can be initialized by |srand()| and will be updated by 8564 rand(). If {expr} is omitted, an internal seed value is used 8565 and updated. 8566 Returns -1 if {expr} is invalid. 8567 8568 Examples: >vim 8569 echo rand() 8570 let seed = srand() 8571 echo rand(seed) 8572 echo rand(seed) % 16 " random number 0 - 15 8573 < 8574 ]=], 8575 name = 'rand', 8576 params = { { 'expr', 'number' } }, 8577 signature = 'rand([{expr}])', 8578 }, 8579 range = { 8580 args = { 1, 3 }, 8581 base = 1, 8582 desc = [=[ 8583 Returns a |List| with Numbers: 8584 - If only {expr} is specified: [0, 1, ..., {expr} - 1] 8585 - If {max} is specified: [{expr}, {expr} + 1, ..., {max}] 8586 - If {stride} is specified: [{expr}, {expr} + {stride}, ..., 8587 {max}] (increasing {expr} with {stride} each time, not 8588 producing a value past {max}). 8589 When the maximum is one before the start the result is an 8590 empty list. When the maximum is more than one before the 8591 start this is an error. 8592 Examples: >vim 8593 echo range(4) " [0, 1, 2, 3] 8594 echo range(2, 4) " [2, 3, 4] 8595 echo range(2, 9, 3) " [2, 5, 8] 8596 echo range(2, -2, -1) " [2, 1, 0, -1, -2] 8597 echo range(0) " [] 8598 echo range(2, 0) " error! 8599 < 8600 ]=], 8601 name = 'range', 8602 params = { { 'expr', 'any' }, { 'max', 'integer' }, { 'stride', 'integer' } }, 8603 signature = 'range({expr} [, {max} [, {stride}]])', 8604 tags = { 'E726', 'E727' }, 8605 }, 8606 readblob = { 8607 args = { 1, 3 }, 8608 base = 1, 8609 desc = [=[ 8610 Read file {fname} in binary mode and return a |Blob|. 8611 If {offset} is specified, read the file from the specified 8612 offset. If it is a negative value, it is used as an offset 8613 from the end of the file. E.g., to read the last 12 bytes: >vim 8614 echo readblob('file.bin', -12) 8615 <If {size} is specified, only the specified size will be read. 8616 E.g. to read the first 100 bytes of a file: >vim 8617 echo readblob('file.bin', 0, 100) 8618 <If {size} is -1 or omitted, the whole data starting from 8619 {offset} will be read. 8620 This can be also used to read the data from a character device 8621 on Unix when {size} is explicitly set. Only if the device 8622 supports seeking {offset} can be used. Otherwise it should be 8623 zero. E.g. to read 10 bytes from a serial console: >vim 8624 echo readblob('/dev/ttyS0', 0, 10) 8625 <When the file can't be opened an error message is given and 8626 the result is an empty |Blob|. 8627 When the offset is beyond the end of the file the result is an 8628 empty blob. 8629 When trying to read more bytes than are available the result 8630 is truncated. 8631 Also see |readfile()| and |writefile()|. 8632 ]=], 8633 name = 'readblob', 8634 params = { { 'fname', 'string' }, { 'offset', 'integer' }, { 'size', 'integer' } }, 8635 signature = 'readblob({fname} [, {offset} [, {size}]])', 8636 }, 8637 readdir = { 8638 args = { 1, 2 }, 8639 base = 1, 8640 desc = [=[ 8641 Return a list with file and directory names in {directory}. 8642 You can also use |glob()| if you don't need to do complicated 8643 things, such as limiting the number of matches. 8644 8645 When {expr} is omitted all entries are included. 8646 When {expr} is given, it is evaluated to check what to do: 8647 If {expr} results in -1 then no further entries will 8648 be handled. 8649 If {expr} results in 0 then this entry will not be 8650 added to the list. 8651 If {expr} results in 1 then this entry will be added 8652 to the list. 8653 Each time {expr} is evaluated |v:val| is set to the entry name. 8654 When {expr} is a function the name is passed as the argument. 8655 For example, to get a list of files ending in ".txt": >vim 8656 echo readdir(dirname, {n -> n =~ '.txt$'}) 8657 <To skip hidden and backup files: >vim 8658 echo readdir(dirname, {n -> n !~ '^\.\|\~$'}) 8659 8660 <If you want to get a directory tree: >vim 8661 function! s:tree(dir) 8662 return {a:dir : map(readdir(a:dir), 8663 \ {_, x -> isdirectory(x) ? 8664 \ {x : s:tree(a:dir .. '/' .. x)} : x})} 8665 endfunction 8666 echo s:tree(".") 8667 < 8668 Returns an empty List on error. 8669 8670 ]=], 8671 name = 'readdir', 8672 params = { { 'directory', 'string' }, { 'expr', 'integer' } }, 8673 signature = 'readdir({directory} [, {expr}])', 8674 }, 8675 readfile = { 8676 args = { 1, 3 }, 8677 base = 1, 8678 desc = [=[ 8679 Read file {fname} and return a |List|, each line of the file 8680 as an item. Lines are broken at NL characters. Macintosh 8681 files separated with CR will result in a single long line 8682 (unless a NL appears somewhere). 8683 All NUL characters are replaced with a NL character. 8684 When {type} contains "b" binary mode is used: 8685 - When the last line ends in a NL an extra empty list item is 8686 added. 8687 - No CR characters are removed. 8688 Otherwise: 8689 - CR characters that appear before a NL are removed. 8690 - Whether the last line ends in a NL or not does not matter. 8691 - Any UTF-8 byte order mark is removed from the text. 8692 When {max} is given this specifies the maximum number of lines 8693 to be read. Useful if you only want to check the first ten 8694 lines of a file: >vim 8695 for line in readfile(fname, '', 10) 8696 if line =~ 'Date' | echo line | endif 8697 endfor 8698 <When {max} is negative -{max} lines from the end of the file 8699 are returned, or as many as there are. 8700 When {max} is zero the result is an empty list. 8701 Note that without {max} the whole file is read into memory. 8702 Also note that there is no recognition of encoding. Read a 8703 file into a buffer if you need to. 8704 Deprecated (use |readblob()| instead): When {type} contains 8705 "B" a |Blob| is returned with the binary data of the file 8706 unmodified. 8707 When the file can't be opened an error message is given and 8708 the result is an empty list. 8709 Also see |writefile()|. 8710 8711 ]=], 8712 name = 'readfile', 8713 params = { { 'fname', 'string' }, { 'type', 'string' }, { 'max', 'integer' } }, 8714 returns = 'string[]', 8715 signature = 'readfile({fname} [, {type} [, {max}]])', 8716 }, 8717 reduce = { 8718 args = { 2, 3 }, 8719 base = 1, 8720 tags = { 'E998' }, 8721 desc = [=[ 8722 {func} is called for every item in {object}, which can be a 8723 |String|, |List| or a |Blob|. {func} is called with two 8724 arguments: the result so far and current item. After 8725 processing all items the result is returned. 8726 8727 {initial} is the initial result. When omitted, the first item 8728 in {object} is used and {func} is first called for the second 8729 item. If {initial} is not given and {object} is empty no 8730 result can be computed, an E998 error is given. 8731 8732 Examples: >vim 8733 echo reduce([1, 3, 5], { acc, val -> acc + val }) 8734 echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a') 8735 echo reduce(0z1122, { acc, val -> 2 * acc + val }) 8736 echo reduce('xyz', { acc, val -> acc .. ',' .. val }) 8737 < 8738 ]=], 8739 name = 'reduce', 8740 generics = { 'T' }, 8741 params = { 8742 { 'object', 'any' }, 8743 { 'func', 'fun(accumulator: T, current: any): any' }, 8744 { 'initial', 'any' }, 8745 }, 8746 returns = 'T', 8747 signature = 'reduce({object}, {func} [, {initial}])', 8748 }, 8749 reg_executing = { 8750 desc = [=[ 8751 Returns the single letter name of the register being executed. 8752 Returns an empty string when no register is being executed. 8753 See |@|. 8754 ]=], 8755 name = 'reg_executing', 8756 params = {}, 8757 signature = 'reg_executing()', 8758 }, 8759 reg_recorded = { 8760 desc = [=[ 8761 Returns the single letter name of the last recorded register. 8762 Returns an empty string when nothing was recorded yet. 8763 See |q| and |Q|. 8764 ]=], 8765 name = 'reg_recorded', 8766 params = {}, 8767 signature = 'reg_recorded()', 8768 }, 8769 reg_recording = { 8770 desc = [=[ 8771 Returns the single letter name of the register being recorded. 8772 Returns an empty string when not recording. See |q|. 8773 ]=], 8774 name = 'reg_recording', 8775 params = {}, 8776 signature = 'reg_recording()', 8777 }, 8778 reltime = { 8779 args = { 0, 2 }, 8780 base = 1, 8781 fast = true, 8782 name = 'reltime', 8783 params = {}, 8784 signature = 'reltime()', 8785 }, 8786 reltime__1 = { 8787 args = { 0, 2 }, 8788 base = 1, 8789 fast = true, 8790 name = 'reltime', 8791 params = { { 'start', 'any' } }, 8792 signature = 'reltime({start})', 8793 }, 8794 reltime__2 = { 8795 args = { 0, 2 }, 8796 base = 1, 8797 desc = [=[ 8798 Return an item that represents a time value. The item is a 8799 list with items that depend on the system. 8800 The item can be passed to |reltimestr()| to convert it to a 8801 string or |reltimefloat()| to convert to a Float. 8802 8803 Without an argument it returns the current "relative time", an 8804 implementation-defined value meaningful only when used as an 8805 argument to |reltime()|, |reltimestr()| and |reltimefloat()|. 8806 8807 With one argument it returns the time passed since the time 8808 specified in the argument. 8809 With two arguments it returns the time passed between {start} 8810 and {end}. 8811 8812 The {start} and {end} arguments must be values returned by 8813 reltime(). Returns zero on error. 8814 8815 Note: |localtime()| returns the current (non-relative) time. 8816 ]=], 8817 fast = true, 8818 name = 'reltime', 8819 params = { { 'start', 'any' }, { 'end', 'any' } }, 8820 signature = 'reltime({start}, {end})', 8821 }, 8822 reltimefloat = { 8823 args = 1, 8824 base = 1, 8825 desc = [=[ 8826 Return a Float that represents the time value of {time}. 8827 Unit of time is seconds. 8828 Example: 8829 let start = reltime() 8830 call MyFunction() 8831 let seconds = reltimefloat(reltime(start)) 8832 See the note of |reltimestr()| about overhead. 8833 Also see |profiling|. 8834 If there is an error an empty string is returned 8835 8836 ]=], 8837 fast = true, 8838 name = 'reltimefloat', 8839 params = { { 'time', 'any' } }, 8840 signature = 'reltimefloat({time})', 8841 }, 8842 reltimestr = { 8843 args = 1, 8844 base = 1, 8845 desc = [=[ 8846 Return a String that represents the time value of {time}. 8847 This is the number of seconds, a dot and the number of 8848 microseconds. Example: >vim 8849 let start = reltime() 8850 call MyFunction() 8851 echo reltimestr(reltime(start)) 8852 <Note that overhead for the commands will be added to the time. 8853 Leading spaces are used to make the string align nicely. You 8854 can use |split()| to remove it. >vim 8855 echo split(reltimestr(reltime(start)))[0] 8856 <Also see |profiling|. 8857 If there is an error an empty string is returned 8858 8859 ]=], 8860 fast = true, 8861 name = 'reltimestr', 8862 params = { { 'time', 'any' } }, 8863 signature = 'reltimestr({time})', 8864 }, 8865 remove = { 8866 args = { 2, 3 }, 8867 base = 1, 8868 name = 'remove', 8869 params = { { 'list', 'any' }, { 'idx', 'integer' } }, 8870 signature = 'remove({list}, {idx})', 8871 }, 8872 remove__1 = { 8873 args = { 2, 3 }, 8874 base = 1, 8875 desc = [=[ 8876 Without {end}: Remove the item at {idx} from |List| {list} and 8877 return the item. 8878 With {end}: Remove items from {idx} to {end} (inclusive) and 8879 return a |List| with these items. When {idx} points to the same 8880 item as {end} a list with one item is returned. When {end} 8881 points to an item before {idx} this is an error. 8882 See |list-index| for possible values of {idx} and {end}. 8883 Returns zero on error. 8884 Example: >vim 8885 echo "last item: " .. remove(mylist, -1) 8886 call remove(mylist, 0, 9) 8887 < 8888 Use |delete()| to remove a file. 8889 8890 ]=], 8891 name = 'remove', 8892 params = { { 'list', 'any[]' }, { 'idx', 'integer' }, { 'end', 'integer' } }, 8893 signature = 'remove({list}, {idx}, {end})', 8894 }, 8895 remove__2 = { 8896 args = { 2, 3 }, 8897 base = 1, 8898 name = 'remove', 8899 params = { { 'blob', 'any' }, { 'idx', 'integer' } }, 8900 signature = 'remove({blob}, {idx})', 8901 }, 8902 remove__3 = { 8903 args = { 2, 3 }, 8904 base = 1, 8905 desc = [=[ 8906 Without {end}: Remove the byte at {idx} from |Blob| {blob} and 8907 return the byte. 8908 With {end}: Remove bytes from {idx} to {end} (inclusive) and 8909 return a |Blob| with these bytes. When {idx} points to the same 8910 byte as {end} a |Blob| with one byte is returned. When {end} 8911 points to a byte before {idx} this is an error. 8912 Returns zero on error. 8913 Example: >vim 8914 echo "last byte: " .. remove(myblob, -1) 8915 call remove(mylist, 0, 9) 8916 < 8917 ]=], 8918 name = 'remove', 8919 params = { { 'blob', 'any' }, { 'idx', 'integer' }, { 'end', 'integer' } }, 8920 signature = 'remove({blob}, {idx}, {end})', 8921 }, 8922 remove__4 = { 8923 args = { 2, 3 }, 8924 base = 1, 8925 desc = [=[ 8926 Remove the entry from {dict} with key {key} and return it. 8927 Example: >vim 8928 echo "removed " .. remove(dict, "one") 8929 <If there is no {key} in {dict} this is an error. 8930 Returns zero on error. 8931 ]=], 8932 name = 'remove', 8933 params = { { 'dict', 'any' }, { 'key', 'string' } }, 8934 signature = 'remove({dict}, {key})', 8935 }, 8936 rename = { 8937 args = 2, 8938 base = 1, 8939 desc = [=[ 8940 Rename the file by the name {from} to the name {to}. This 8941 should also work to move files across file systems. The 8942 result is a Number, which is 0 if the file was renamed 8943 successfully, and non-zero when the renaming failed. 8944 NOTE: If {to} exists it is overwritten without warning. 8945 This function is not available in the |sandbox|. 8946 8947 ]=], 8948 name = 'rename', 8949 params = { { 'from', 'string' }, { 'to', 'string' } }, 8950 returns = 'integer', 8951 signature = 'rename({from}, {to})', 8952 }, 8953 ['repeat'] = { 8954 args = 2, 8955 base = 1, 8956 desc = [=[ 8957 Repeat {expr} {count} times and return the concatenated 8958 result. Example: >vim 8959 let separator = repeat('-', 80) 8960 <When {count} is zero or negative the result is empty. 8961 When {expr} is a |List| or a |Blob| the result is {expr} 8962 concatenated {count} times. Example: >vim 8963 let longlist = repeat(['a', 'b'], 3) 8964 <Results in ['a', 'b', 'a', 'b', 'a', 'b']. 8965 8966 ]=], 8967 fast = true, 8968 name = 'repeat', 8969 params = { { 'expr', 'any' }, { 'count', 'integer' } }, 8970 signature = 'repeat({expr}, {count})', 8971 }, 8972 resolve = { 8973 args = 1, 8974 base = 1, 8975 tags = { 'E655' }, 8976 desc = [=[ 8977 On MS-Windows, when {filename} is a shortcut (a .lnk file), 8978 returns the path the shortcut points to in a simplified form. 8979 On Unix, repeat resolving symbolic links in all path 8980 components of {filename} and return the simplified result. 8981 To cope with link cycles, resolving of symbolic links is 8982 stopped after 100 iterations. 8983 On other systems, return the simplified {filename}. 8984 The simplification step is done as by |simplify()|. 8985 resolve() keeps a leading path component specifying the 8986 current directory (provided the result is still a relative 8987 path name) and also keeps a trailing path separator. 8988 8989 ]=], 8990 fast = true, 8991 name = 'resolve', 8992 params = { { 'filename', 'string' } }, 8993 returns = 'string', 8994 signature = 'resolve({filename})', 8995 }, 8996 reverse = { 8997 args = 1, 8998 base = 1, 8999 desc = [=[ 9000 Reverse the order of items in {object}. {object} can be a 9001 |List|, a |Blob| or a |String|. For a List and a Blob the 9002 items are reversed in-place and {object} is returned. 9003 For a String a new String is returned. 9004 Returns zero if {object} is not a List, Blob or a String. 9005 If you want a List or Blob to remain unmodified make a copy 9006 first: >vim 9007 let revlist = reverse(copy(mylist)) 9008 < 9009 ]=], 9010 name = 'reverse', 9011 generics = { 'T' }, 9012 params = { { 'object', 'T[]' } }, 9013 returns = 'T[]', 9014 signature = 'reverse({object})', 9015 }, 9016 round = { 9017 args = 1, 9018 base = 1, 9019 desc = [=[ 9020 Round off {expr} to the nearest integral value and return it 9021 as a |Float|. If {expr} lies halfway between two integral 9022 values, then use the larger one (away from zero). 9023 {expr} must evaluate to a |Float| or a |Number|. 9024 Returns 0.0 if {expr} is not a |Float| or a |Number|. 9025 Examples: >vim 9026 echo round(0.456) 9027 < 0.0 >vim 9028 echo round(4.5) 9029 < 5.0 >vim 9030 echo round(-4.5) 9031 < -5.0 9032 9033 ]=], 9034 float_func = 'round', 9035 name = 'round', 9036 params = { { 'expr', 'number' } }, 9037 returns = 'number', 9038 signature = 'round({expr})', 9039 }, 9040 rpcnotify = { 9041 args = { 2 }, 9042 desc = [=[ 9043 Sends {event} to {channel} via |RPC| and returns immediately. 9044 If {channel} is 0, the event is broadcast to all channels. 9045 Example: >vim 9046 au VimLeave call rpcnotify(0, "leaving") 9047 < 9048 ]=], 9049 name = 'rpcnotify', 9050 params = { { 'channel', 'integer' }, { 'event', 'string' }, { '...', 'any' } }, 9051 returns = 'integer', 9052 signature = 'rpcnotify({channel}, {event} [, {args}...])', 9053 }, 9054 rpcrequest = { 9055 args = { 2 }, 9056 desc = [=[ 9057 Sends a request to {channel} to invoke {method} via 9058 |RPC| and blocks until a response is received. 9059 Example: >vim 9060 let result = rpcrequest(rpc_chan, "func", 1, 2, 3) 9061 < 9062 ]=], 9063 name = 'rpcrequest', 9064 params = { { 'channel', 'integer' }, { 'method', 'string' }, { '...', 'any' } }, 9065 signature = 'rpcrequest({channel}, {method} [, {args}...])', 9066 }, 9067 rpcstart = { 9068 deprecated = true, 9069 args = { 1, 2 }, 9070 desc = [=[ 9071 Deprecated. Replace >vim 9072 let id = rpcstart('prog', ['arg1', 'arg2']) 9073 <with >vim 9074 let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true}) 9075 < 9076 ]=], 9077 name = 'rpcstart', 9078 params = { { 'prog', 'string' }, { 'argv', 'any' } }, 9079 signature = 'rpcstart({prog} [, {argv}])', 9080 }, 9081 rpcstop = { 9082 args = 1, 9083 deprecated = true, 9084 desc = [=[ 9085 Use |jobstop()| instead to stop any job, or 9086 `chanclose(id, "rpc")` to close RPC communication 9087 without stopping the job. Use chanclose(id) to close 9088 any socket. 9089 ]=], 9090 params = VARARGS, 9091 signature = 'rpcstop(...)', 9092 }, 9093 rubyeval = { 9094 args = 1, 9095 base = 1, 9096 desc = [=[ 9097 Evaluate Ruby expression {expr} and return its result 9098 converted to Vim data structures. 9099 Numbers, floats and strings are returned as they are (strings 9100 are copied though). 9101 Arrays are represented as Vim |List| type. 9102 Hashes are represented as Vim |Dictionary| type. 9103 Other objects are represented as strings resulted from their 9104 "Object#to_s" method. 9105 9106 ]=], 9107 name = 'rubyeval', 9108 params = { { 'expr', 'any' } }, 9109 signature = 'rubyeval({expr})', 9110 }, 9111 screenattr = { 9112 args = 2, 9113 base = 1, 9114 desc = [=[ 9115 Like |screenchar()|, but return the attribute. This is a rather 9116 arbitrary number that can only be used to compare to the 9117 attribute at other positions. 9118 Returns -1 when row or col is out of range. 9119 9120 ]=], 9121 name = 'screenattr', 9122 params = { { 'row', 'integer' }, { 'col', 'integer' } }, 9123 returns = 'integer', 9124 signature = 'screenattr({row}, {col})', 9125 }, 9126 screenchar = { 9127 args = 2, 9128 base = 1, 9129 desc = [=[ 9130 The result is a Number, which is the character at position 9131 [row, col] on the screen. This works for every possible 9132 screen position, also status lines, window separators and the 9133 command line. The top left position is row one, column one 9134 The character excludes composing characters. For double-byte 9135 encodings it may only be the first byte. 9136 This is mainly to be used for testing. 9137 Returns -1 when row or col is out of range. 9138 9139 ]=], 9140 name = 'screenchar', 9141 params = { { 'row', 'integer' }, { 'col', 'integer' } }, 9142 returns = 'integer', 9143 signature = 'screenchar({row}, {col})', 9144 }, 9145 screenchars = { 9146 args = 2, 9147 base = 1, 9148 desc = [=[ 9149 The result is a |List| of Numbers. The first number is the same 9150 as what |screenchar()| returns. Further numbers are 9151 composing characters on top of the base character. 9152 This is mainly to be used for testing. 9153 Returns an empty List when row or col is out of range. 9154 9155 ]=], 9156 name = 'screenchars', 9157 params = { { 'row', 'integer' }, { 'col', 'integer' } }, 9158 returns = 'integer[]', 9159 signature = 'screenchars({row}, {col})', 9160 }, 9161 screencol = { 9162 desc = [=[ 9163 The result is a Number, which is the current screen column of 9164 the cursor. The leftmost column has number 1. 9165 This function is mainly used for testing. 9166 9167 Note: Always returns the current screen column, thus if used 9168 in a command (e.g. ":echo screencol()") it will return the 9169 column inside the command line, which is 1 when the command is 9170 executed. To get the cursor position in the file use one of 9171 the following mappings: >vim 9172 nnoremap <expr> GG ":echom " .. screencol() .. "\n" 9173 nnoremap <silent> GG :echom screencol()<CR> 9174 noremap GG <Cmd>echom screencol()<CR> 9175 < 9176 ]=], 9177 name = 'screencol', 9178 params = {}, 9179 returns = 'integer[]', 9180 signature = 'screencol()', 9181 }, 9182 screenpos = { 9183 args = 3, 9184 base = 1, 9185 desc = [=[ 9186 The result is a Dict with the screen position of the text 9187 character in window {winid} at buffer line {lnum} and column 9188 {col}. {col} is a one-based byte index. 9189 The Dict has these members: 9190 row screen row 9191 col first screen column 9192 endcol last screen column 9193 curscol cursor screen column 9194 If the specified position is not visible, all values are zero. 9195 The "endcol" value differs from "col" when the character 9196 occupies more than one screen cell. E.g. for a Tab "col" can 9197 be 1 and "endcol" can be 8. 9198 The "curscol" value is where the cursor would be placed. For 9199 a Tab it would be the same as "endcol", while for a double 9200 width character it would be the same as "col". 9201 The |conceal| feature is ignored here, the column numbers are 9202 as if 'conceallevel' is zero. You can set the cursor to the 9203 right position and use |screencol()| to get the value with 9204 |conceal| taken into account. 9205 If the position is in a closed fold the screen position of the 9206 first character is returned, {col} is not used. 9207 Returns an empty Dict if {winid} is invalid. 9208 9209 ]=], 9210 name = 'screenpos', 9211 params = { { 'winid', 'integer' }, { 'lnum', 'integer' }, { 'col', 'integer' } }, 9212 signature = 'screenpos({winid}, {lnum}, {col})', 9213 }, 9214 screenrow = { 9215 desc = [=[ 9216 The result is a Number, which is the current screen row of the 9217 cursor. The top line has number one. 9218 This function is mainly used for testing. 9219 Alternatively you can use |winline()|. 9220 9221 Note: Same restrictions as with |screencol()|. 9222 ]=], 9223 name = 'screenrow', 9224 params = {}, 9225 returns = 'integer', 9226 signature = 'screenrow()', 9227 }, 9228 screenstring = { 9229 args = 2, 9230 base = 1, 9231 desc = [=[ 9232 The result is a String that contains the base character and 9233 any composing characters at position [row, col] on the screen. 9234 This is like |screenchars()| but returning a String with the 9235 characters. 9236 This is mainly to be used for testing. 9237 Returns an empty String when row or col is out of range. 9238 9239 ]=], 9240 name = 'screenstring', 9241 params = { { 'row', 'integer' }, { 'col', 'integer' } }, 9242 returns = 'string', 9243 signature = 'screenstring({row}, {col})', 9244 }, 9245 search = { 9246 args = { 1, 5 }, 9247 base = 1, 9248 desc = [=[ 9249 Search for regexp pattern {pattern}. The search starts at the 9250 cursor position (you can use |cursor()| to set it). 9251 9252 When a match has been found its line number is returned. 9253 If there is no match a 0 is returned and the cursor doesn't 9254 move. No error message is given. 9255 To get the matched string, use |matchbufline()|. 9256 9257 {flags} is a String, which can contain these character flags: 9258 'b' search Backward instead of forward 9259 'c' accept a match at the Cursor position 9260 'e' move to the End of the match 9261 'n' do Not move the cursor 9262 'p' return number of matching sub-Pattern (see below) 9263 's' Set the ' mark at the previous location of the cursor 9264 'w' Wrap around the end of the file 9265 'W' don't Wrap around the end of the file 9266 'z' start searching at the cursor column instead of Zero 9267 If neither 'w' or 'W' is given, the 'wrapscan' option applies. 9268 9269 If the 's' flag is supplied, the ' mark is set, only if the 9270 cursor is moved. The 's' flag cannot be combined with the 'n' 9271 flag. 9272 9273 'ignorecase', 'smartcase' and 'magic' are used. 9274 9275 When the 'z' flag is not given, forward searching always 9276 starts in column zero and then matches before the cursor are 9277 skipped. When the 'c' flag is present in 'cpo' the next 9278 search starts after the match. Without the 'c' flag the next 9279 search starts one column after the start of the match. This 9280 matters for overlapping matches. See |cpo-c|. You can also 9281 insert "\ze" to change where the match ends, see |/\ze|. 9282 9283 When searching backwards and the 'z' flag is given then the 9284 search starts in column zero, thus no match in the current 9285 line will be found (unless wrapping around the end of the 9286 file). 9287 9288 When the {stopline} argument is given then the search stops 9289 after searching this line. This is useful to restrict the 9290 search to a range of lines. Examples: >vim 9291 let match = search('(', 'b', line("w0")) 9292 let end = search('END', '', line("w$")) 9293 <When {stopline} is used and it is not zero this also implies 9294 that the search does not wrap around the end of the file. 9295 A zero value is equal to not giving the argument. 9296 9297 When the {timeout} argument is given the search stops when 9298 more than this many milliseconds have passed. Thus when 9299 {timeout} is 500 the search stops after half a second. 9300 The value must not be negative. A zero value is like not 9301 giving the argument. 9302 9303 Note: the timeout is only considered when searching, not 9304 while evaluating the {skip} expression. 9305 9306 If the {skip} expression is given it is evaluated with the 9307 cursor positioned on the start of a match. If it evaluates to 9308 non-zero this match is skipped. This can be used, for 9309 example, to skip a match in a comment or a string. 9310 {skip} can be a string, which is evaluated as an expression, a 9311 function reference or a lambda. 9312 When {skip} is omitted or empty, every match is accepted. 9313 When evaluating {skip} causes an error the search is aborted 9314 and -1 returned. 9315 *search()-sub-match* 9316 With the 'p' flag the returned value is one more than the 9317 first sub-match in \(\). One if none of them matched but the 9318 whole pattern did match. 9319 To get the column number too use |searchpos()|. 9320 9321 The cursor will be positioned at the match, unless the 'n' 9322 flag is used. 9323 9324 Example (goes over all files in the argument list): >vim 9325 let n = 1 9326 while n <= argc() " loop over all files in arglist 9327 exe "argument " .. n 9328 " start at the last char in the file and wrap for the 9329 " first search to find match at start of file 9330 normal G$ 9331 let flags = "w" 9332 while search("foo", flags) > 0 9333 s/foo/bar/g 9334 let flags = "W" 9335 endwhile 9336 update " write the file if modified 9337 let n = n + 1 9338 endwhile 9339 < 9340 Example for using some flags: >vim 9341 echo search('\<if\|\(else\)\|\(endif\)', 'ncpe') 9342 <This will search for the keywords "if", "else", and "endif" 9343 under or after the cursor. Because of the 'p' flag, it 9344 returns 1, 2, or 3 depending on which keyword is found, or 0 9345 if the search fails. With the cursor on the first word of the 9346 line: 9347 if (foo == 0) | let foo = foo + 1 | endif ~ 9348 the function returns 1. Without the 'c' flag, the function 9349 finds the "endif" and returns 3. The same thing happens 9350 without the 'e' flag if the cursor is on the "f" of "if". 9351 The 'n' flag tells the function not to move the cursor. 9352 9353 ]=], 9354 name = 'search', 9355 params = { 9356 { 'pattern', 'string' }, 9357 { 'flags', 'string' }, 9358 { 'stopline', 'integer' }, 9359 { 'timeout', 'integer' }, 9360 { 'skip', 'string|function' }, 9361 }, 9362 returns = 'integer', 9363 signature = 'search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])', 9364 }, 9365 searchcount = { 9366 args = { 0, 1 }, 9367 base = 1, 9368 desc = [=[ 9369 Get or update the last search count, like what is displayed 9370 without the "S" flag in 'shortmess'. This works even if 9371 'shortmess' does contain the "S" flag. 9372 9373 This returns a |Dictionary|. The dictionary is empty if the 9374 previous pattern was not set and "pattern" was not specified. 9375 9376 key type meaning ~ 9377 current |Number| current position of match; 9378 0 if the cursor position is 9379 before the first match 9380 exact_match |Boolean| 1 if "current" is matched on 9381 "pos", otherwise 0 9382 total |Number| total count of matches found 9383 incomplete |Number| 0: search was fully completed 9384 1: recomputing was timed out 9385 2: max count exceeded 9386 9387 For {options} see further down. 9388 9389 To get the last search count when |n| or |N| was pressed, call 9390 this function with `recompute: 0` . This sometimes returns 9391 wrong information because of 'maxsearchcount'. 9392 If the count exceeded 'maxsearchcount', the result must be 9393 'maxsearchcount' + 1. If you want to get correct information, 9394 specify `recompute: 1`: >vim 9395 9396 " result == 'maxsearchcount' + 1 when many matches 9397 let result = searchcount(#{recompute: 0}) 9398 9399 " Below returns correct result (recompute defaults 9400 " to 1) 9401 let result = searchcount() 9402 < 9403 The function is useful to add the count to 'statusline': >vim 9404 function! LastSearchCount() abort 9405 let result = searchcount(#{recompute: 0}) 9406 if empty(result) 9407 return '' 9408 endif 9409 if result.incomplete ==# 1 " timed out 9410 return printf(' /%s [?/??]', @/) 9411 elseif result.incomplete ==# 2 " max count exceeded 9412 if result.total > result.maxcount && 9413 \ result.current > result.maxcount 9414 return printf(' /%s [>%d/>%d]', @/, 9415 \ result.current, result.total) 9416 elseif result.total > result.maxcount 9417 return printf(' /%s [%d/>%d]', @/, 9418 \ result.current, result.total) 9419 endif 9420 endif 9421 return printf(' /%s [%d/%d]', @/, 9422 \ result.current, result.total) 9423 endfunction 9424 let &statusline ..= '%{LastSearchCount()}' 9425 9426 " Or if you want to show the count only when 9427 " 'hlsearch' was on 9428 " let &statusline ..= 9429 " \ '%{v:hlsearch ? LastSearchCount() : ""}' 9430 < 9431 You can also update the search count, which can be useful in a 9432 |CursorMoved| or |CursorMovedI| autocommand: >vim 9433 9434 autocmd CursorMoved,CursorMovedI * 9435 \ let s:searchcount_timer = timer_start( 9436 \ 200, function('s:update_searchcount')) 9437 function! s:update_searchcount(timer) abort 9438 if a:timer ==# s:searchcount_timer 9439 call searchcount(#{ 9440 \ recompute: 1, maxcount: 0, timeout: 100}) 9441 redrawstatus 9442 endif 9443 endfunction 9444 < 9445 This can also be used to count matched texts with specified 9446 pattern in the current buffer using "pattern": >vim 9447 9448 " Count '\<foo\>' in this buffer 9449 " (Note that it also updates search count) 9450 let result = searchcount(#{pattern: '\<foo\>'}) 9451 9452 " To restore old search count by old pattern, 9453 " search again 9454 call searchcount() 9455 < 9456 {options} must be a |Dictionary|. It can contain: 9457 key type meaning ~ 9458 recompute |Boolean| if |TRUE|, recompute the count 9459 like |n| or |N| was executed. 9460 otherwise returns the last 9461 computed result (when |n| or 9462 |N| was used when "S" is not 9463 in 'shortmess', or this 9464 function was called). 9465 (default: |TRUE|) 9466 pattern |String| recompute if this was given 9467 and different with |@/|. 9468 this works as same as the 9469 below command is executed 9470 before calling this function >vim 9471 let @/ = pattern 9472 < (default: |@/|) 9473 timeout |Number| 0 or negative number is no 9474 timeout. timeout milliseconds 9475 for recomputing the result 9476 (default: 0) 9477 maxcount |Number| 0 or negative number is no 9478 limit. max count of matched 9479 text while recomputing the 9480 result. if search exceeded 9481 total count, "total" value 9482 becomes `maxcount + 1` 9483 (default: 'maxsearchcount') 9484 pos |List| `[lnum, col, off]` value 9485 when recomputing the result. 9486 this changes "current" result 9487 value. see |cursor()|, |getpos()| 9488 (default: cursor's position) 9489 9490 ]=], 9491 name = 'searchcount', 9492 params = { { 'options', 'table' } }, 9493 signature = 'searchcount([{options}])', 9494 }, 9495 searchdecl = { 9496 args = { 1, 3 }, 9497 base = 1, 9498 desc = [=[ 9499 Search for the declaration of {name}. 9500 9501 With a non-zero {global} argument it works like |gD|, find 9502 first match in the file. Otherwise it works like |gd|, find 9503 first match in the function. 9504 9505 With a non-zero {thisblock} argument matches in a {} block 9506 that ends before the cursor position are ignored. Avoids 9507 finding variable declarations only valid in another scope. 9508 9509 Moves the cursor to the found match. 9510 Returns zero for success, non-zero for failure. 9511 Example: >vim 9512 if searchdecl('myvar') == 0 9513 echo getline('.') 9514 endif 9515 < 9516 ]=], 9517 name = 'searchdecl', 9518 params = { { 'name', 'string' }, { 'global', 'boolean' }, { 'thisblock', 'boolean' } }, 9519 signature = 'searchdecl({name} [, {global} [, {thisblock}]])', 9520 }, 9521 searchpair = { 9522 args = { 3, 7 }, 9523 desc = [=[ 9524 Search for the match of a nested start-end pair. This can be 9525 used to find the "endif" that matches an "if", while other 9526 if/endif pairs in between are ignored. 9527 The search starts at the cursor. The default is to search 9528 forward, include 'b' in {flags} to search backward. 9529 If a match is found, the cursor is positioned at it and the 9530 line number is returned. If no match is found 0 or -1 is 9531 returned and the cursor doesn't move. No error message is 9532 given. 9533 9534 {start}, {middle} and {end} are patterns, see |pattern|. They 9535 must not contain \( \) pairs. Use of \%( \) is allowed. When 9536 {middle} is not empty, it is found when searching from either 9537 direction, but only when not in a nested start-end pair. A 9538 typical use is: >vim 9539 echo searchpair('\<if\>', '\<else\>', '\<endif\>') 9540 <By leaving {middle} empty the "else" is skipped. 9541 9542 {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with 9543 |search()|. Additionally: 9544 'r' Repeat until no more matches found; will find the 9545 outer pair. Implies the 'W' flag. 9546 'm' Return number of matches instead of line number with 9547 the match; will be > 1 when 'r' is used. 9548 Note: it's nearly always a good idea to use the 'W' flag, to 9549 avoid wrapping around the end of the file. 9550 9551 When a match for {start}, {middle} or {end} is found, the 9552 {skip} expression is evaluated with the cursor positioned on 9553 the start of the match. It should return non-zero if this 9554 match is to be skipped. E.g., because it is inside a comment 9555 or a string. 9556 When {skip} is omitted or empty, every match is accepted. 9557 When evaluating {skip} causes an error the search is aborted 9558 and -1 returned. 9559 {skip} can be a string, a lambda, a funcref or a partial. 9560 Anything else makes the function fail. 9561 9562 For {stopline} and {timeout} see |search()|. 9563 9564 The value of 'ignorecase' is used. 'magic' is ignored, the 9565 patterns are used like it's on. 9566 9567 The search starts exactly at the cursor. A match with 9568 {start}, {middle} or {end} at the next character, in the 9569 direction of searching, is the first one found. Example: >vim 9570 if 1 9571 if 2 9572 endif 2 9573 endif 1 9574 <When starting at the "if 2", with the cursor on the "i", and 9575 searching forwards, the "endif 2" is found. When starting on 9576 the character just before the "if 2", the "endif 1" will be 9577 found. That's because the "if 2" will be found first, and 9578 then this is considered to be a nested if/endif from "if 2" to 9579 "endif 2". 9580 When searching backwards and {end} is more than one character, 9581 it may be useful to put "\zs" at the end of the pattern, so 9582 that when the cursor is inside a match with the end it finds 9583 the matching start. 9584 9585 Example, to find the "endif" command in a Vim script: >vim 9586 9587 echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W', 9588 \ 'getline(".") =~ "^\\s*\""') 9589 9590 <The cursor must be at or after the "if" for which a match is 9591 to be found. Note that single-quote strings are used to avoid 9592 having to double the backslashes. The skip expression only 9593 catches comments at the start of a line, not after a command. 9594 Also, a word "en" or "if" halfway through a line is considered 9595 a match. 9596 Another example, to search for the matching "{" of a "}": >vim 9597 9598 echo searchpair('{', '', '}', 'bW') 9599 9600 <This works when the cursor is at or before the "}" for which a 9601 match is to be found. To reject matches that syntax 9602 highlighting recognized as strings: >vim 9603 9604 echo searchpair('{', '', '}', 'bW', 9605 \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') 9606 < 9607 ]=], 9608 name = 'searchpair', 9609 params = { 9610 { 'start', 'string' }, 9611 { 'middle', 'string' }, 9612 { 'end', 'string' }, 9613 { 'flags', 'string' }, 9614 { 'skip', 'string|function' }, 9615 { 'stopline', 'integer' }, 9616 { 'timeout', 'integer' }, 9617 }, 9618 returns = 'integer', 9619 signature = 'searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])', 9620 }, 9621 searchpairpos = { 9622 args = { 3, 7 }, 9623 desc = [=[ 9624 Same as |searchpair()|, but returns a |List| with the line and 9625 column position of the match. The first element of the |List| 9626 is the line number and the second element is the byte index of 9627 the column position of the match. If no match is found, 9628 returns [0, 0]. >vim 9629 9630 let [lnum,col] = searchpairpos('{', '', '}', 'n') 9631 < 9632 See |match-parens| for a bigger and more useful example. 9633 ]=], 9634 name = 'searchpairpos', 9635 params = { 9636 { 'start', 'string' }, 9637 { 'middle', 'string' }, 9638 { 'end', 'string' }, 9639 { 'flags', 'string' }, 9640 { 'skip', 'string|function' }, 9641 { 'stopline', 'integer' }, 9642 { 'timeout', 'integer' }, 9643 }, 9644 returns = '[integer, integer]', 9645 signature = 'searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])', 9646 }, 9647 searchpos = { 9648 args = { 1, 5 }, 9649 base = 1, 9650 desc = [=[ 9651 Same as |search()|, but returns a |List| with the line and 9652 column position of the match. The first element of the |List| 9653 is the line number and the second element is the byte index of 9654 the column position of the match. If no match is found, 9655 returns [0, 0]. 9656 Example: >vim 9657 let [lnum, col] = searchpos('mypattern', 'n') 9658 9659 <When the 'p' flag is given then there is an extra item with 9660 the sub-pattern match number |search()-sub-match|. Example: >vim 9661 let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np') 9662 <In this example "submatch" is 2 when a lowercase letter is 9663 found |/\l|, 3 when an uppercase letter is found |/\u|. 9664 9665 ]=], 9666 name = 'searchpos', 9667 params = { 9668 { 'pattern', 'string' }, 9669 { 'flags', 'string' }, 9670 { 'stopline', 'integer' }, 9671 { 'timeout', 'integer' }, 9672 { 'skip', 'string|function' }, 9673 }, 9674 signature = 'searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])', 9675 }, 9676 serverlist = { 9677 args = { 0, 1 }, 9678 desc = [=[ 9679 Returns a list of server addresses, or empty if all servers 9680 were stopped. |serverstart()| |serverstop()| 9681 9682 The optional argument {opts} is a Dict and supports the following items: 9683 9684 peer : If |TRUE|, servers not started by |serverstart()| 9685 will also be returned. (default: |FALSE|) 9686 Not supported on Windows yet. 9687 9688 Example: >vim 9689 echo serverlist() 9690 < 9691 ]=], 9692 name = 'serverlist', 9693 params = { { 'opts', 'table' } }, 9694 returns = 'string[]', 9695 signature = 'serverlist([{opts}])', 9696 }, 9697 serverstart = { 9698 args = { 0, 1 }, 9699 desc = [=[ 9700 Opens a socket or named pipe at {address} and listens for 9701 |RPC| messages. Clients can send |API| commands to the 9702 returned address to control Nvim. 9703 9704 Returns the address string (which may differ from the 9705 {address} argument, see below). 9706 9707 - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address 9708 where the last ":" separates host and port (empty or zero 9709 assigns a random port). 9710 - Else {address} is the path to a named pipe (except on Windows). 9711 - If {address} has no slashes ("/") it is treated as the 9712 "name" part of a generated path in this format: >vim 9713 stdpath("run").."/{name}.{pid}.{counter}" 9714 < - If {address} is omitted the name is "nvim". >vim 9715 echo serverstart() 9716 < > 9717 => /tmp/nvim.bram/oknANW/nvim.15430.5 9718 < 9719 Example bash command to list all Nvim servers: >bash 9720 ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0 9721 9722 <Example named pipe: >vim 9723 if has('win32') 9724 echo serverstart('\\.\pipe\nvim-pipe-1234') 9725 else 9726 echo serverstart('nvim.sock') 9727 endif 9728 < 9729 Example TCP/IP address: >vim 9730 echo serverstart('::1:12345') 9731 < 9732 ]=], 9733 name = 'serverstart', 9734 params = { { 'address', 'string' } }, 9735 returns = 'string', 9736 signature = 'serverstart([{address}])', 9737 }, 9738 serverstop = { 9739 args = 1, 9740 desc = [=[ 9741 Closes the pipe or socket at {address}. 9742 Returns TRUE if {address} is valid, else FALSE. 9743 If |v:servername| is stopped it is set to the next available 9744 address in |serverlist()|. 9745 ]=], 9746 name = 'serverstop', 9747 params = { { 'address', 'string' } }, 9748 returns = 'integer', 9749 signature = 'serverstop({address})', 9750 }, 9751 setbufline = { 9752 args = 3, 9753 base = 3, 9754 desc = [=[ 9755 Set line {lnum} to {text} in buffer {buf}. This works like 9756 |setline()| for the specified buffer. 9757 9758 This function works only for loaded buffers. First call 9759 |bufload()| if needed. 9760 9761 To insert lines use |appendbufline()|. 9762 9763 {text} can be a string to set one line, or a List of strings 9764 to set multiple lines. If the List extends below the last 9765 line then those lines are added. If the List is empty then 9766 nothing is changed and zero is returned. 9767 9768 For the use of {buf}, see |bufname()| above. 9769 9770 {lnum} is used like with |setline()|. 9771 Use "$" to refer to the last line in buffer {buf}. 9772 When {lnum} is just below the last line the {text} will be 9773 added below the last line. 9774 On success 0 is returned, on failure 1 is returned. 9775 9776 If {buf} is not a valid buffer or {lnum} is not valid, an 9777 error message is given. 9778 9779 ]=], 9780 name = 'setbufline', 9781 params = { { 'buf', 'integer|string' }, { 'lnum', 'integer' }, { 'text', 'string|string[]' } }, 9782 returns = 'integer', 9783 signature = 'setbufline({buf}, {lnum}, {text})', 9784 }, 9785 setbufvar = { 9786 args = 3, 9787 base = 3, 9788 desc = [=[ 9789 Set option or local variable {varname} in buffer {buf} to 9790 {val}. 9791 This also works for a global or local window option, but it 9792 doesn't work for a global or local window variable. 9793 For a local window option the global value is unchanged. 9794 For the use of {buf}, see |bufname()| above. 9795 The {varname} argument is a string. 9796 Note that the variable name without "b:" must be used. 9797 Examples: >vim 9798 call setbufvar(1, "&mod", 1) 9799 call setbufvar("todo", "myvar", "foobar") 9800 <This function is not available in the |sandbox|. 9801 9802 ]=], 9803 name = 'setbufvar', 9804 params = { { 'buf', 'integer|string' }, { 'varname', 'string' }, { 'val', 'any' } }, 9805 signature = 'setbufvar({buf}, {varname}, {val})', 9806 }, 9807 setcellwidths = { 9808 args = 1, 9809 base = 1, 9810 desc = [=[ 9811 Specify overrides for cell widths of character ranges. This 9812 tells Vim how wide characters are when displayed in the 9813 terminal, counted in screen cells. The values override 9814 'ambiwidth'. Example: >vim 9815 call setcellwidths([ 9816 \ [0x111, 0x111, 1], 9817 \ [0x2194, 0x2199, 2], 9818 \ ]) 9819 9820 <The {list} argument is a List of Lists with each three 9821 numbers: [{low}, {high}, {width}]. *E1109* *E1110* 9822 {low} and {high} can be the same, in which case this refers to 9823 one character. Otherwise it is the range of characters from 9824 {low} to {high} (inclusive). *E1111* *E1114* 9825 Only characters with value 0x80 and higher can be used. 9826 9827 {width} must be either 1 or 2, indicating the character width 9828 in screen cells. *E1112* 9829 An error is given if the argument is invalid, also when a 9830 range overlaps with another. *E1113* 9831 9832 If the new value causes 'fillchars' or 'listchars' to become 9833 invalid it is rejected and an error is given. 9834 9835 To clear the overrides pass an empty {list}: >vim 9836 call setcellwidths([]) 9837 9838 <You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see 9839 the effect for known emoji characters. Move the cursor 9840 through the text to check if the cell widths of your terminal 9841 match with what Vim knows about each emoji. If it doesn't 9842 look right you need to adjust the {list} argument. 9843 ]=], 9844 name = 'setcellwidths', 9845 params = { { 'list', 'any[]' } }, 9846 signature = 'setcellwidths({list})', 9847 }, 9848 setcharpos = { 9849 args = 2, 9850 base = 2, 9851 desc = [=[ 9852 Same as |setpos()| but uses the specified column number as the 9853 character index instead of the byte index in the line. 9854 9855 Example: 9856 With the text "여보세요" in line 8: >vim 9857 call setcharpos('.', [0, 8, 4, 0]) 9858 <positions the cursor on the fourth character '요'. >vim 9859 call setpos('.', [0, 8, 4, 0]) 9860 <positions the cursor on the second character '보'. 9861 9862 ]=], 9863 name = 'setcharpos', 9864 params = { { 'expr', 'string' }, { 'list', 'integer[]' } }, 9865 signature = 'setcharpos({expr}, {list})', 9866 }, 9867 setcharsearch = { 9868 args = 1, 9869 base = 1, 9870 desc = [=[ 9871 Set the current character search information to {dict}, 9872 which contains one or more of the following entries: 9873 9874 char character which will be used for a subsequent 9875 |,| or |;| command; an empty string clears the 9876 character search 9877 forward direction of character search; 1 for forward, 9878 0 for backward 9879 until type of character search; 1 for a |t| or |T| 9880 character search, 0 for an |f| or |F| 9881 character search 9882 9883 This can be useful to save/restore a user's character search 9884 from a script: >vim 9885 let prevsearch = getcharsearch() 9886 " Perform a command which clobbers user's search 9887 call setcharsearch(prevsearch) 9888 <Also see |getcharsearch()|. 9889 9890 ]=], 9891 name = 'setcharsearch', 9892 params = { { 'dict', '{ char?: string, forward?: 1|0, until?: 1|0 }' } }, 9893 signature = 'setcharsearch({dict})', 9894 }, 9895 setcmdline = { 9896 args = { 1, 2 }, 9897 base = 1, 9898 desc = [=[ 9899 Set the command line to {str} and set the cursor position to 9900 {pos}. 9901 If {pos} is omitted, the cursor is positioned after the text. 9902 Returns 0 when successful, 1 when not editing the command 9903 line. 9904 9905 ]=], 9906 name = 'setcmdline', 9907 params = { { 'str', 'string' }, { 'pos', 'integer' } }, 9908 returns = 'integer', 9909 signature = 'setcmdline({str} [, {pos}])', 9910 }, 9911 setcmdpos = { 9912 args = 1, 9913 base = 1, 9914 desc = [=[ 9915 Set the cursor position in the command line to byte position 9916 {pos}. The first position is 1. 9917 Use |getcmdpos()| to obtain the current position. 9918 Only works while editing the command line, thus you must use 9919 |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For 9920 |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is 9921 set after the command line is set to the expression. For 9922 |c_CTRL-R_=| it is set after evaluating the expression but 9923 before inserting the resulting text. 9924 When the number is too big the cursor is put at the end of the 9925 line. A number smaller than one has undefined results. 9926 Returns 0 when successful, 1 when not editing the command 9927 line. 9928 9929 ]=], 9930 name = 'setcmdpos', 9931 params = { { 'pos', 'integer' } }, 9932 signature = 'setcmdpos({pos})', 9933 }, 9934 setcursorcharpos = { 9935 args = { 1, 3 }, 9936 base = 1, 9937 name = 'setcursorcharpos', 9938 params = { { 'lnum', 'integer|string' }, { 'col', 'integer' }, { 'off', 'integer' } }, 9939 signature = 'setcursorcharpos({lnum}, {col} [, {off}])', 9940 }, 9941 setcursorcharpos__1 = { 9942 args = { 1, 3 }, 9943 base = 1, 9944 desc = [=[ 9945 Same as |cursor()| but uses the specified column number as the 9946 character index instead of the byte index in the line. 9947 9948 Example: 9949 With the text "여보세요" in line 4: >vim 9950 call setcursorcharpos(4, 3) 9951 <positions the cursor on the third character '세'. >vim 9952 call cursor(4, 3) 9953 <positions the cursor on the first character '여'. 9954 9955 Returns 0 when the position could be set, -1 otherwise. 9956 ]=], 9957 name = 'setcursorcharpos', 9958 params = { { 'list', 'integer[]' } }, 9959 signature = 'setcursorcharpos({list})', 9960 }, 9961 setenv = { 9962 args = 2, 9963 base = 2, 9964 desc = [=[ 9965 Set environment variable {name} to {val}. Example: >vim 9966 call setenv('HOME', '/home/myhome') 9967 9968 <When {val} is |v:null| the environment variable is deleted. 9969 See also |expr-env|. 9970 9971 ]=], 9972 name = 'setenv', 9973 params = { { 'name', 'string' }, { 'val', 'string' } }, 9974 signature = 'setenv({name}, {val})', 9975 }, 9976 setfperm = { 9977 args = 2, 9978 base = 1, 9979 tags = { 'chmod' }, 9980 desc = [=[ 9981 Set the file permissions for {fname} to {mode}. 9982 {mode} must be a string with 9 characters. It is of the form 9983 "rwxrwxrwx", where each group of "rwx" flags represent, in 9984 turn, the permissions of the owner of the file, the group the 9985 file belongs to, and other users. A '-' character means the 9986 permission is off, any other character means on. Multi-byte 9987 characters are not supported. 9988 9989 For example "rw-r-----" means read-write for the user, 9990 readable by the group, not accessible by others. "xx-x-----" 9991 would do the same thing. 9992 9993 Returns non-zero for success, zero for failure. 9994 9995 To read permissions see |getfperm()|. 9996 ]=], 9997 name = 'setfperm', 9998 params = { { 'fname', 'string' }, { 'mode', 'string' } }, 9999 signature = 'setfperm({fname}, {mode})', 10000 }, 10001 setline = { 10002 args = 2, 10003 base = 2, 10004 desc = [=[ 10005 Set line {lnum} of the current buffer to {text}. To insert 10006 lines use |append()|. To set lines in another buffer use 10007 |setbufline()|. 10008 10009 {lnum} is used like with |getline()|. 10010 When {lnum} is just below the last line the {text} will be 10011 added below the last line. 10012 {text} can be any type or a List of any type, each item is 10013 converted to a String. When {text} is an empty List then 10014 nothing is changed and FALSE is returned. 10015 10016 If this succeeds, FALSE is returned. If this fails (most 10017 likely because {lnum} is invalid) TRUE is returned. 10018 10019 Example: >vim 10020 call setline(5, strftime("%c")) 10021 10022 <When {text} is a |List| then line {lnum} and following lines 10023 will be set to the items in the list. Example: >vim 10024 call setline(5, ['aaa', 'bbb', 'ccc']) 10025 <This is equivalent to: >vim 10026 for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']] 10027 call setline(n, l) 10028 endfor 10029 10030 <Note: The '[ and '] marks are not set. 10031 10032 ]=], 10033 name = 'setline', 10034 params = { { 'lnum', 'integer|string' }, { 'text', 'any' } }, 10035 signature = 'setline({lnum}, {text})', 10036 }, 10037 setloclist = { 10038 args = { 2, 4 }, 10039 base = 2, 10040 desc = [=[ 10041 Create or replace or add to the location list for window {nr}. 10042 {nr} can be the window number or the |window-ID|. 10043 When {nr} is zero the current window is used. 10044 10045 For a location list window, the displayed location list is 10046 modified. For an invalid window number {nr}, -1 is returned. 10047 Otherwise, same as |setqflist()|. 10048 Also see |location-list|. 10049 10050 For {action} see |setqflist-action|. 10051 10052 If the optional {what} dictionary argument is supplied, then 10053 only the items listed in {what} are set. Refer to |setqflist()| 10054 for the list of supported keys in {what}. 10055 10056 ]=], 10057 name = 'setloclist', 10058 params = { 10059 { 'nr', 'integer' }, 10060 { 'list', 'vim.quickfix.entry[]' }, 10061 { 'action', 'string' }, 10062 { 'what', 'vim.fn.setqflist.what' }, 10063 }, 10064 signature = 'setloclist({nr}, {list} [, {action} [, {what}]])', 10065 }, 10066 setmatches = { 10067 args = { 1, 2 }, 10068 base = 1, 10069 desc = [=[ 10070 Restores a list of matches saved by |getmatches()| for the 10071 current window. Returns 0 if successful, otherwise -1. All 10072 current matches are cleared before the list is restored. See 10073 example for |getmatches()|. 10074 If {win} is specified, use the window with this number or 10075 window ID instead of the current window. 10076 10077 ]=], 10078 name = 'setmatches', 10079 params = { { 'list', 'vim.fn.getmatches.ret.item[]' }, { 'win', 'integer' } }, 10080 signature = 'setmatches({list} [, {win}])', 10081 }, 10082 setpos = { 10083 args = 2, 10084 base = 2, 10085 desc = [=[ 10086 Set the position for String {expr}. Possible values: 10087 . the cursor 10088 'x mark x 10089 10090 {list} must be a |List| with four or five numbers: 10091 [bufnum, lnum, col, off] 10092 [bufnum, lnum, col, off, curswant] 10093 10094 "bufnum" is the buffer number. Zero can be used for the 10095 current buffer. When setting an uppercase mark "bufnum" is 10096 used for the mark position. For other marks it specifies the 10097 buffer to set the mark in. You can use the |bufnr()| function 10098 to turn a file name into a buffer number. 10099 For setting the cursor and the ' mark "bufnum" is ignored, 10100 since these are associated with a window, not a buffer. 10101 Does not change the jumplist. 10102 10103 "lnum" and "col" are the position in the buffer. The first 10104 column is 1. Use a zero "lnum" to delete a mark. If "col" is 10105 smaller than 1 then 1 is used. To use the character count 10106 instead of the byte count, use |setcharpos()|. 10107 10108 The "off" number is only used when 'virtualedit' is set. Then 10109 it is the offset in screen columns from the start of the 10110 character. E.g., a position within a <Tab> or after the last 10111 character. 10112 10113 The "curswant" number is only used when setting the cursor 10114 position. It sets the preferred column for when moving the 10115 cursor vertically. When the "curswant" number is missing the 10116 preferred column is not set. When it is present and setting a 10117 mark position it is not used. 10118 10119 Note that for |'<| and |'>| changing the line number may 10120 result in the marks to be effectively swapped, so that |'<| is 10121 always before |'>|. 10122 10123 The visual marks |'<| and |'>| refer to the beginning and end 10124 of the visual selection relative to the cursor position. 10125 Note that this differs from |getpos()|, where they are 10126 relative to the buffer. 10127 10128 Returns 0 when the position could be set, -1 otherwise. 10129 An error message is given if {expr} is invalid. 10130 10131 Also see |setcharpos()|, |getpos()| and |getcurpos()|. 10132 10133 This does not restore the preferred column for moving 10134 vertically; if you set the cursor position with this, |j| and 10135 |k| motions will jump to previous columns! Use |cursor()| to 10136 also set the preferred column. Also see the "curswant" key in 10137 |winrestview()|. 10138 10139 ]=], 10140 name = 'setpos', 10141 params = { { 'expr', 'string' }, { 'list', 'integer[]' } }, 10142 signature = 'setpos({expr}, {list})', 10143 }, 10144 setqflist = { 10145 args = { 1, 3 }, 10146 base = 1, 10147 desc = [=[ 10148 Create or replace or add to the quickfix list. 10149 10150 If the optional {what} dictionary argument is supplied, then 10151 only the items listed in {what} are set. The first {list} 10152 argument is ignored. See below for the supported items in 10153 {what}. 10154 *setqflist-what* 10155 When {what} is not present, the items in {list} are used. 10156 Each item must be a dictionary. Non-dictionary items in 10157 {list} are ignored. Each dictionary item can contain the 10158 following entries: 10159 10160 bufnr buffer number; must be the number of a valid 10161 buffer 10162 filename name of a file; only used when "bufnr" is not 10163 present or it is invalid. 10164 module name of a module; if given it will be used in 10165 quickfix error window instead of the filename. 10166 lnum line number in the file 10167 end_lnum end of lines, if the item spans multiple lines 10168 pattern search pattern used to locate the error 10169 col column number 10170 vcol when non-zero: "col" is visual column 10171 when zero: "col" is byte index 10172 end_col end column, if the item spans multiple columns 10173 nr error number 10174 text description of the error 10175 type single-character error type, 'E', 'W', etc. 10176 valid recognized error message 10177 user_data 10178 custom data associated with the item, can be 10179 any type. 10180 10181 The "col", "vcol", "nr", "type" and "text" entries are 10182 optional. Either "lnum" or "pattern" entry can be used to 10183 locate a matching error line. 10184 If the "filename" and "bufnr" entries are not present or 10185 neither the "lnum" or "pattern" entries are present, then the 10186 item will not be handled as an error line. 10187 If both "pattern" and "lnum" are present then "pattern" will 10188 be used. 10189 If the "valid" entry is not supplied, then the valid flag is 10190 set when "bufnr" is a valid buffer or "filename" exists. 10191 If you supply an empty {list}, the quickfix list will be 10192 cleared. 10193 Note that the list is not exactly the same as what 10194 |getqflist()| returns. 10195 10196 {action} values: *setqflist-action* *E927* 10197 'a' The items from {list} are added to the existing 10198 quickfix list. If there is no existing list, then a 10199 new list is created. 10200 10201 'r' The items from the current quickfix list are replaced 10202 with the items from {list}. This can also be used to 10203 clear the list: >vim 10204 call setqflist([], 'r') 10205 < 10206 'u' Like 'r', but tries to preserve the current selection 10207 in the quickfix list. 10208 'f' All the quickfix lists in the quickfix stack are 10209 freed. 10210 10211 If {action} is not present or is set to ' ', then a new list 10212 is created. The new quickfix list is added after the current 10213 quickfix list in the stack and all the following lists are 10214 freed. To add a new quickfix list at the end of the stack, 10215 set "nr" in {what} to "$". 10216 10217 The following items can be specified in dictionary {what}: 10218 context quickfix list context. See |quickfix-context| 10219 efm errorformat to use when parsing text from 10220 "lines". If this is not present, then the 10221 'errorformat' option value is used. 10222 See |quickfix-parse| 10223 id quickfix list identifier |quickfix-ID| 10224 idx index of the current entry in the quickfix 10225 list specified by "id" or "nr". If set to 10226 '$', then the last entry in the list is set as 10227 the current entry. See |quickfix-index| 10228 items list of quickfix entries. Same as the {list} 10229 argument. 10230 lines use 'errorformat' to parse a list of lines and 10231 add the resulting entries to the quickfix list 10232 {nr} or {id}. Only a |List| value is supported. 10233 See |quickfix-parse| 10234 nr list number in the quickfix stack; zero 10235 means the current quickfix list and "$" means 10236 the last quickfix list. 10237 quickfixtextfunc 10238 function to get the text to display in the 10239 quickfix window. The value can be the name of 10240 a function or a funcref or a lambda. Refer to 10241 |quickfix-window-function| for an explanation 10242 of how to write the function and an example. 10243 title quickfix list title text. See |quickfix-title| 10244 Unsupported keys in {what} are ignored. 10245 If the "nr" item is not present, then the current quickfix 10246 list is modified. When creating a new quickfix list, "nr" can 10247 be set to a value one greater than the quickfix stack size. 10248 When modifying a quickfix list, to guarantee that the correct 10249 list is modified, "id" should be used instead of "nr" to 10250 specify the list. 10251 10252 Examples (See also |setqflist-examples|): >vim 10253 call setqflist([], 'r', {'title': 'My search'}) 10254 call setqflist([], 'r', {'nr': 2, 'title': 'Errors'}) 10255 call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]}) 10256 < 10257 Returns zero for success, -1 for failure. 10258 10259 This function can be used to create a quickfix list 10260 independent of the 'errorformat' setting. Use a command like 10261 `:cc 1` to jump to the first position. 10262 10263 ]=], 10264 name = 'setqflist', 10265 params = { 10266 { 'list', 'vim.quickfix.entry[]' }, 10267 { 'action', 'string' }, 10268 { 'what', 'vim.fn.setqflist.what' }, 10269 }, 10270 returns = 'integer', 10271 signature = 'setqflist({list} [, {action} [, {what}]])', 10272 }, 10273 setreg = { 10274 args = { 2, 3 }, 10275 base = 2, 10276 desc = [=[ 10277 Set the register {regname} to {value}. 10278 If {regname} is "" or "@", the unnamed register '"' is used. 10279 The {regname} argument is a string. 10280 10281 {value} may be any value returned by |getreg()| or 10282 |getreginfo()|, including a |List| or |Dict|. 10283 If {options} contains "a" or {regname} is upper case, 10284 then the value is appended. 10285 10286 {options} can also contain a register type specification: 10287 "c" or "v" |charwise| mode 10288 "l" or "V" |linewise| mode 10289 "b" or "<CTRL-V>" |blockwise-visual| mode 10290 If a number immediately follows "b" or "<CTRL-V>" then this is 10291 used as the width of the selection - if it is not specified 10292 then the width of the block is set to the number of characters 10293 in the longest line (counting a <Tab> as 1 character). 10294 If {options} contains "u" or '"', then the unnamed register is 10295 set to point to register {regname}. 10296 10297 If {options} contains no register settings, then the default 10298 is to use character mode unless {value} ends in a <NL> for 10299 string {value} and linewise mode for list {value}. Blockwise 10300 mode is never selected automatically. 10301 Returns zero for success, non-zero for failure. 10302 10303 *E883* 10304 Note: you may not use |List| containing more than one item to 10305 set search and expression registers. Lists containing 10306 no items act like empty strings. 10307 10308 Examples: >vim 10309 call setreg(v:register, @*) 10310 call setreg('*', @%, 'ac') 10311 call setreg('a', "1\n2\n3", 'b5') 10312 call setreg('"', { 'points_to': 'a'}) 10313 10314 <This example shows using the functions to save and restore a 10315 register: >vim 10316 let var_a = getreginfo() 10317 call setreg('a', var_a) 10318 <or: >vim 10319 let var_a = getreg('a', 1, 1) 10320 let var_amode = getregtype('a') 10321 " .... 10322 call setreg('a', var_a, var_amode) 10323 <Note: you may not reliably restore register value 10324 without using the third argument to |getreg()| as without it 10325 newlines are represented as newlines AND Nul bytes are 10326 represented as newlines as well, see |NL-used-for-Nul|. 10327 10328 You can also change the type of a register by appending 10329 nothing: >vim 10330 call setreg('a', '', 'al') 10331 < 10332 ]=], 10333 name = 'setreg', 10334 params = { { 'regname', 'string' }, { 'value', 'any' }, { 'options', 'string' } }, 10335 signature = 'setreg({regname}, {value} [, {options}])', 10336 }, 10337 settabvar = { 10338 args = 3, 10339 base = 3, 10340 desc = [=[ 10341 Set tab-local variable {varname} to {val} in tab page {tabnr}. 10342 |t:var| 10343 The {varname} argument is a string. 10344 Note that the variable name without "t:" must be used. 10345 Tabs are numbered starting with one. 10346 This function is not available in the |sandbox|. 10347 10348 ]=], 10349 name = 'settabvar', 10350 params = { { 'tabnr', 'integer' }, { 'varname', 'string' }, { 'val', 'any' } }, 10351 signature = 'settabvar({tabnr}, {varname}, {val})', 10352 }, 10353 settabwinvar = { 10354 args = 4, 10355 base = 4, 10356 desc = [=[ 10357 Set option or local variable {varname} in window {winnr} to 10358 {val}. 10359 Tabs are numbered starting with one. For the current tabpage 10360 use |setwinvar()|. 10361 {winnr} can be the window number or the |window-ID|. 10362 When {winnr} is zero the current window is used. 10363 This also works for a global or local buffer option, but it 10364 doesn't work for a global or local buffer variable. 10365 For a local buffer option the global value is unchanged. 10366 Note that the variable name without "w:" must be used. 10367 Examples: >vim 10368 call settabwinvar(1, 1, "&list", 0) 10369 call settabwinvar(3, 2, "myvar", "foobar") 10370 <This function is not available in the |sandbox|. 10371 10372 ]=], 10373 name = 'settabwinvar', 10374 params = { 10375 { 'tabnr', 'integer' }, 10376 { 'winnr', 'integer' }, 10377 { 'varname', 'string' }, 10378 { 'val', 'any' }, 10379 }, 10380 signature = 'settabwinvar({tabnr}, {winnr}, {varname}, {val})', 10381 }, 10382 settagstack = { 10383 args = { 2, 3 }, 10384 base = 2, 10385 desc = [=[ 10386 Modify the tag stack of the window {nr} using {dict}. 10387 {nr} can be the window number or the |window-ID|. 10388 10389 For a list of supported items in {dict}, refer to 10390 |gettagstack()|. "curidx" takes effect before changing the tag 10391 stack. 10392 *E962* 10393 How the tag stack is modified depends on the {action} 10394 argument: 10395 - If {action} is not present or is set to 'r', then the tag 10396 stack is replaced. 10397 - If {action} is set to 'a', then new entries from {dict} are 10398 pushed (added) onto the tag stack. 10399 - If {action} is set to 't', then all the entries from the 10400 current entry in the tag stack or "curidx" in {dict} are 10401 removed and then new entries are pushed to the stack. 10402 10403 The current index is set to one after the length of the tag 10404 stack after the modification. 10405 10406 Returns zero for success, -1 for failure. 10407 10408 Examples (for more examples see |tagstack-examples|): 10409 Empty the tag stack of window 3: >vim 10410 call settagstack(3, {'items' : []}) 10411 10412 < Save and restore the tag stack: >vim 10413 let stack = gettagstack(1003) 10414 " do something else 10415 call settagstack(1003, stack) 10416 unlet stack 10417 < 10418 ]=], 10419 name = 'settagstack', 10420 params = { { 'nr', 'integer' }, { 'dict', 'any' }, { 'action', 'string' } }, 10421 signature = 'settagstack({nr}, {dict} [, {action}])', 10422 }, 10423 setwinvar = { 10424 args = 3, 10425 base = 3, 10426 desc = [=[ 10427 Like |settabwinvar()| for the current tab page. 10428 Examples: >vim 10429 call setwinvar(1, "&list", 0) 10430 call setwinvar(2, "myvar", "foobar") 10431 < 10432 ]=], 10433 name = 'setwinvar', 10434 params = { { 'nr', 'integer' }, { 'varname', 'string' }, { 'val', 'any' } }, 10435 signature = 'setwinvar({nr}, {varname}, {val})', 10436 }, 10437 sha256 = { 10438 args = 1, 10439 base = 1, 10440 desc = [=[ 10441 Returns a String with 64 hex characters, which is the SHA256 10442 checksum of {expr}. 10443 {expr} is a String or a Blob. 10444 10445 ]=], 10446 name = 'sha256', 10447 params = { { 'expr', 'string' } }, 10448 returns = 'string', 10449 signature = 'sha256({expr})', 10450 }, 10451 shellescape = { 10452 args = { 1, 2 }, 10453 base = 1, 10454 desc = [=[ 10455 Escape {string} for use as a shell command argument. 10456 10457 On Windows when 'shellslash' is not set, encloses {string} in 10458 double-quotes and doubles all double-quotes within {string}. 10459 Otherwise encloses {string} in single-quotes and replaces all 10460 "'" with "'\''". 10461 10462 The {special} argument adds additional escaping of keywords 10463 used in Vim commands. If it is a |non-zero-arg|: 10464 - Special items such as "!", "%", "#" and "<cword>" (as listed 10465 in |expand()|) will be preceded by a backslash. 10466 The backslash will be removed again by the |:!| command. 10467 - The <NL> character is escaped. 10468 10469 If 'shell' contains "csh" in the tail: 10470 - The "!" character will be escaped. This is because csh and 10471 tcsh use "!" for history replacement even in single-quotes. 10472 - The <NL> character is escaped (twice if {special} is 10473 a |non-zero-arg|). 10474 10475 If 'shell' contains "fish" in the tail, the "\" character will 10476 be escaped because in fish it is used as an escape character 10477 inside single quotes. 10478 10479 Example of use with a |:!| command: >vim 10480 exe '!dir ' .. shellescape(expand('<cfile>'), 1) 10481 <This results in a directory listing for the file under the 10482 cursor. Example of use with |system()|: >vim 10483 call system("chmod +w -- " .. shellescape(expand("%"))) 10484 <See also |::S|. 10485 10486 ]=], 10487 name = 'shellescape', 10488 params = { { 'string', 'string' }, { 'special', 'boolean' } }, 10489 returns = 'string', 10490 signature = 'shellescape({string} [, {special}])', 10491 }, 10492 shiftwidth = { 10493 args = { 0, 1 }, 10494 base = 1, 10495 desc = [=[ 10496 Returns the effective value of 'shiftwidth'. This is the 10497 'shiftwidth' value unless it is zero, in which case it is the 10498 'tabstop' value. To be backwards compatible in indent 10499 plugins, use this: >vim 10500 if exists('*shiftwidth') 10501 func s:sw() 10502 return shiftwidth() 10503 endfunc 10504 else 10505 func s:sw() 10506 return &sw 10507 endfunc 10508 endif 10509 <And then use s:sw() instead of &sw. 10510 10511 for which to return the 'shiftwidth' value. This matters for 10512 the 'vartabstop' feature. If the 'vartabstop' setting is 10513 enabled and no {col} argument is given, column 1 will be 10514 assumed. 10515 10516 ]=], 10517 name = 'shiftwidth', 10518 params = { { 'col', 'integer' } }, 10519 signature = 'shiftwidth([{col}])', 10520 returns = 'integer', 10521 }, 10522 sign_define = { 10523 args = { 1, 2 }, 10524 base = 1, 10525 name = 'sign_define', 10526 params = { { 'name', 'string' }, { 'dict', 'vim.fn.sign_define.dict' } }, 10527 signature = 'sign_define({name} [, {dict}])', 10528 returns = '0|-1', 10529 }, 10530 sign_define__1 = { 10531 args = { 1, 2 }, 10532 base = 1, 10533 desc = [=[ 10534 Define a new sign named {name} or modify the attributes of an 10535 existing sign. This is similar to the |:sign-define| command. 10536 10537 Prefix {name} with a unique text to avoid name collisions. 10538 There is no {group} like with placing signs. 10539 10540 The {name} can be a String or a Number. The optional {dict} 10541 argument specifies the sign attributes. The following values 10542 are supported: 10543 icon full path to the bitmap file for the sign. 10544 linehl highlight group used for the whole line the 10545 sign is placed in. 10546 priority default priority value of the sign 10547 numhl highlight group used for the line number where 10548 the sign is placed. 10549 text text that is displayed when there is no icon 10550 or the GUI is not being used. 10551 texthl highlight group used for the text item 10552 culhl highlight group used for the text item when 10553 the cursor is on the same line as the sign and 10554 'cursorline' is enabled. 10555 10556 If the sign named {name} already exists, then the attributes 10557 of the sign are updated. 10558 10559 The one argument {list} can be used to define a list of signs. 10560 Each list item is a dictionary with the above items in {dict} 10561 and a "name" item for the sign name. 10562 10563 Returns 0 on success and -1 on failure. When the one argument 10564 {list} is used, then returns a List of values one for each 10565 defined sign. 10566 10567 Examples: >vim 10568 call sign_define("mySign", { 10569 \ "text" : "=>", 10570 \ "texthl" : "Error", 10571 \ "linehl" : "Search"}) 10572 call sign_define([ 10573 \ {'name' : 'sign1', 10574 \ 'text' : '=>'}, 10575 \ {'name' : 'sign2', 10576 \ 'text' : '!!'} 10577 \ ]) 10578 < 10579 ]=], 10580 name = 'sign_define', 10581 params = { { 'list', 'vim.fn.sign_define.dict[]' } }, 10582 signature = 'sign_define({list})', 10583 returns = '(0|-1)[]', 10584 }, 10585 sign_getdefined = { 10586 args = { 0, 1 }, 10587 base = 1, 10588 desc = [=[ 10589 Get a list of defined signs and their attributes. 10590 This is similar to the |:sign-list| command. 10591 10592 If the {name} is not supplied, then a list of all the defined 10593 signs is returned. Otherwise the attribute of the specified 10594 sign is returned. 10595 10596 Each list item in the returned value is a dictionary with the 10597 following entries: 10598 icon full path to the bitmap file of the sign 10599 linehl highlight group used for the whole line the 10600 sign is placed in; not present if not set. 10601 name name of the sign 10602 priority default priority value of the sign 10603 numhl highlight group used for the line number where 10604 the sign is placed; not present if not set. 10605 text text that is displayed when there is no icon 10606 or the GUI is not being used. 10607 texthl highlight group used for the text item; not 10608 present if not set. 10609 culhl highlight group used for the text item when 10610 the cursor is on the same line as the sign and 10611 'cursorline' is enabled; not present if not 10612 set. 10613 10614 Returns an empty List if there are no signs and when {name} is 10615 not found. 10616 10617 Examples: >vim 10618 " Get a list of all the defined signs 10619 echo sign_getdefined() 10620 10621 " Get the attribute of the sign named mySign 10622 echo sign_getdefined("mySign") 10623 < 10624 ]=], 10625 name = 'sign_getdefined', 10626 params = { { 'name', 'string' } }, 10627 signature = 'sign_getdefined([{name}])', 10628 returns = 'vim.fn.sign_getdefined.ret.item[]', 10629 }, 10630 sign_getplaced = { 10631 args = { 0, 2 }, 10632 base = 1, 10633 desc = [=[ 10634 Return a list of signs placed in a buffer or all the buffers. 10635 This is similar to the |:sign-place-list| command. 10636 10637 If the optional buffer name {buf} is specified, then only the 10638 list of signs placed in that buffer is returned. For the use 10639 of {buf}, see |bufname()|. The optional {dict} can contain 10640 the following entries: 10641 group select only signs in this group 10642 id select sign with this identifier 10643 lnum select signs placed in this line. For the use 10644 of {lnum}, see |line()|. 10645 If {group} is "*", then signs in all the groups including the 10646 global group are returned. If {group} is not supplied or is 10647 an empty string, then only signs in the global group are 10648 returned. If no arguments are supplied, then signs in the 10649 global group placed in all the buffers are returned. 10650 See |sign-group|. 10651 10652 Each list item in the returned value is a dictionary with the 10653 following entries: 10654 bufnr number of the buffer with the sign 10655 signs list of signs placed in {bufnr}. Each list 10656 item is a dictionary with the below listed 10657 entries 10658 10659 The dictionary for each sign contains the following entries: 10660 group sign group. Set to '' for the global group. 10661 id identifier of the sign 10662 lnum line number where the sign is placed 10663 name name of the defined sign 10664 priority sign priority 10665 10666 The returned signs in a buffer are ordered by their line 10667 number and priority. 10668 10669 Returns an empty list on failure or if there are no placed 10670 signs. 10671 10672 Examples: >vim 10673 " Get a List of signs placed in eval.c in the 10674 " global group 10675 echo sign_getplaced("eval.c") 10676 10677 " Get a List of signs in group 'g1' placed in eval.c 10678 echo sign_getplaced("eval.c", {'group' : 'g1'}) 10679 10680 " Get a List of signs placed at line 10 in eval.c 10681 echo sign_getplaced("eval.c", {'lnum' : 10}) 10682 10683 " Get sign with identifier 10 placed in a.py 10684 echo sign_getplaced("a.py", {'id' : 10}) 10685 10686 " Get sign with id 20 in group 'g1' placed in a.py 10687 echo sign_getplaced("a.py", {'group' : 'g1', 10688 \ 'id' : 20}) 10689 10690 " Get a List of all the placed signs 10691 echo sign_getplaced() 10692 < 10693 ]=], 10694 name = 'sign_getplaced', 10695 params = { { 'buf', 'integer|string' }, { 'dict', 'vim.fn.sign_getplaced.dict' } }, 10696 signature = 'sign_getplaced([{buf} [, {dict}]])', 10697 returns = 'vim.fn.sign_getplaced.ret.item[]', 10698 }, 10699 sign_jump = { 10700 args = 3, 10701 base = 1, 10702 desc = [=[ 10703 Open the buffer {buf} or jump to the window that contains 10704 {buf} and position the cursor at sign {id} in group {group}. 10705 This is similar to the |:sign-jump| command. 10706 10707 If {group} is an empty string, then the global group is used. 10708 For the use of {buf}, see |bufname()|. 10709 10710 Returns the line number of the sign. Returns -1 if the 10711 arguments are invalid. 10712 10713 Example: >vim 10714 " Jump to sign 10 in the current buffer 10715 call sign_jump(10, '', '') 10716 < 10717 ]=], 10718 name = 'sign_jump', 10719 params = { { 'id', 'integer' }, { 'group', 'string' }, { 'buf', 'integer|string' } }, 10720 signature = 'sign_jump({id}, {group}, {buf})', 10721 returns = 'integer', 10722 }, 10723 sign_place = { 10724 args = { 4, 5 }, 10725 base = 1, 10726 desc = [=[ 10727 Place the sign defined as {name} at line {lnum} in file or 10728 buffer {buf} and assign {id} and {group} to sign. This is 10729 similar to the |:sign-place| command. 10730 10731 If the sign identifier {id} is zero, then a new identifier is 10732 allocated. Otherwise the specified number is used. {group} 10733 is the sign group name. To use the global sign group, use an 10734 empty string. {group} functions as a namespace for {id}, thus 10735 two groups can use the same IDs. Refer to |sign-identifier| 10736 and |sign-group| for more information. 10737 10738 {name} refers to a defined sign. 10739 {buf} refers to a buffer name or number. For the accepted 10740 values, see |bufname()|. 10741 10742 The optional {dict} argument supports the following entries: 10743 lnum line number in the file or buffer 10744 {buf} where the sign is to be placed. 10745 For the accepted values, see |line()|. 10746 priority priority of the sign. See 10747 |sign-priority| for more information. 10748 10749 If the optional {dict} is not specified, then it modifies the 10750 placed sign {id} in group {group} to use the defined sign 10751 {name}. 10752 10753 Returns the sign identifier on success and -1 on failure. 10754 10755 Examples: >vim 10756 " Place a sign named sign1 with id 5 at line 20 in 10757 " buffer json.c 10758 call sign_place(5, '', 'sign1', 'json.c', 10759 \ {'lnum' : 20}) 10760 10761 " Updates sign 5 in buffer json.c to use sign2 10762 call sign_place(5, '', 'sign2', 'json.c') 10763 10764 " Place a sign named sign3 at line 30 in 10765 " buffer json.c with a new identifier 10766 let id = sign_place(0, '', 'sign3', 'json.c', 10767 \ {'lnum' : 30}) 10768 10769 " Place a sign named sign4 with id 10 in group 'g3' 10770 " at line 40 in buffer json.c with priority 90 10771 call sign_place(10, 'g3', 'sign4', 'json.c', 10772 \ {'lnum' : 40, 'priority' : 90}) 10773 < 10774 ]=], 10775 name = 'sign_place', 10776 params = { 10777 { 'id', 'integer' }, 10778 { 'group', 'string' }, 10779 { 'name', 'string' }, 10780 { 'buf', 'integer|string' }, 10781 { 'dict', 'vim.fn.sign_place.dict' }, 10782 }, 10783 signature = 'sign_place({id}, {group}, {name}, {buf} [, {dict}])', 10784 returns = 'integer', 10785 }, 10786 sign_placelist = { 10787 args = 1, 10788 base = 1, 10789 desc = [=[ 10790 Place one or more signs. This is similar to the 10791 |sign_place()| function. The {list} argument specifies the 10792 List of signs to place. Each list item is a dict with the 10793 following sign attributes: 10794 buffer Buffer name or number. For the accepted 10795 values, see |bufname()|. 10796 group Sign group. {group} functions as a namespace 10797 for {id}, thus two groups can use the same 10798 IDs. If not specified or set to an empty 10799 string, then the global group is used. See 10800 |sign-group| for more information. 10801 id Sign identifier. If not specified or zero, 10802 then a new unique identifier is allocated. 10803 Otherwise the specified number is used. See 10804 |sign-identifier| for more information. 10805 lnum Line number in the buffer where the sign is to 10806 be placed. For the accepted values, see 10807 |line()|. 10808 name Name of the sign to place. See |sign_define()| 10809 for more information. 10810 priority Priority of the sign. When multiple signs are 10811 placed on a line, the sign with the highest 10812 priority is used. If not specified, the 10813 default value of 10 is used, unless specified 10814 otherwise by the sign definition. See 10815 |sign-priority| for more information. 10816 10817 If {id} refers to an existing sign, then the existing sign is 10818 modified to use the specified {name} and/or {priority}. 10819 10820 Returns a List of sign identifiers. If failed to place a 10821 sign, the corresponding list item is set to -1. 10822 10823 Examples: >vim 10824 " Place sign s1 with id 5 at line 20 and id 10 at line 10825 " 30 in buffer a.c 10826 let [n1, n2] = sign_placelist([ 10827 \ {'id' : 5, 10828 \ 'name' : 's1', 10829 \ 'buffer' : 'a.c', 10830 \ 'lnum' : 20}, 10831 \ {'id' : 10, 10832 \ 'name' : 's1', 10833 \ 'buffer' : 'a.c', 10834 \ 'lnum' : 30} 10835 \ ]) 10836 10837 " Place sign s1 in buffer a.c at line 40 and 50 10838 " with auto-generated identifiers 10839 let [n1, n2] = sign_placelist([ 10840 \ {'name' : 's1', 10841 \ 'buffer' : 'a.c', 10842 \ 'lnum' : 40}, 10843 \ {'name' : 's1', 10844 \ 'buffer' : 'a.c', 10845 \ 'lnum' : 50} 10846 \ ]) 10847 < 10848 ]=], 10849 name = 'sign_placelist', 10850 params = { { 'list', 'vim.fn.sign_placelist.list.item[]' } }, 10851 signature = 'sign_placelist({list})', 10852 returns = 'integer[]', 10853 }, 10854 sign_undefine = { 10855 args = { 0, 1 }, 10856 base = 1, 10857 name = 'sign_undefine', 10858 params = { { 'name', 'string' } }, 10859 signature = 'sign_undefine([{name}])', 10860 returns = '0|-1', 10861 }, 10862 sign_undefine__1 = { 10863 args = { 0, 1 }, 10864 base = 1, 10865 desc = [=[ 10866 Deletes a previously defined sign {name}. This is similar to 10867 the |:sign-undefine| command. If {name} is not supplied, then 10868 deletes all the defined signs. 10869 10870 The one argument {list} can be used to undefine a list of 10871 signs. Each list item is the name of a sign. 10872 10873 Returns 0 on success and -1 on failure. For the one argument 10874 {list} call, returns a list of values one for each undefined 10875 sign. 10876 10877 Examples: >vim 10878 " Delete a sign named mySign 10879 call sign_undefine("mySign") 10880 10881 " Delete signs 'sign1' and 'sign2' 10882 call sign_undefine(["sign1", "sign2"]) 10883 10884 " Delete all the signs 10885 call sign_undefine() 10886 < 10887 ]=], 10888 name = 'sign_undefine', 10889 params = { { 'list', 'string[]' } }, 10890 signature = 'sign_undefine({list})', 10891 returns = 'integer[]', 10892 }, 10893 sign_unplace = { 10894 args = { 1, 2 }, 10895 base = 1, 10896 desc = [=[ 10897 Remove a previously placed sign in one or more buffers. This 10898 is similar to the |:sign-unplace| command. 10899 10900 {group} is the sign group name. To use the global sign group, 10901 use an empty string. If {group} is set to "*", then all the 10902 groups including the global group are used. 10903 The signs in {group} are selected based on the entries in 10904 {dict}. The following optional entries in {dict} are 10905 supported: 10906 buffer buffer name or number. See |bufname()|. 10907 id sign identifier 10908 If {dict} is not supplied, then all the signs in {group} are 10909 removed. 10910 10911 Returns 0 on success and -1 on failure. 10912 10913 Examples: >vim 10914 " Remove sign 10 from buffer a.vim 10915 call sign_unplace('', {'buffer' : "a.vim", 'id' : 10}) 10916 10917 " Remove sign 20 in group 'g1' from buffer 3 10918 call sign_unplace('g1', {'buffer' : 3, 'id' : 20}) 10919 10920 " Remove all the signs in group 'g2' from buffer 10 10921 call sign_unplace('g2', {'buffer' : 10}) 10922 10923 " Remove sign 30 in group 'g3' from all the buffers 10924 call sign_unplace('g3', {'id' : 30}) 10925 10926 " Remove all the signs placed in buffer 5 10927 call sign_unplace('*', {'buffer' : 5}) 10928 10929 " Remove the signs in group 'g4' from all the buffers 10930 call sign_unplace('g4') 10931 10932 " Remove sign 40 from all the buffers 10933 call sign_unplace('*', {'id' : 40}) 10934 10935 " Remove all the placed signs from all the buffers 10936 call sign_unplace('*') 10937 < 10938 ]=], 10939 name = 'sign_unplace', 10940 params = { { 'group', 'string' }, { 'dict', 'vim.fn.sign_unplace.dict' } }, 10941 signature = 'sign_unplace({group} [, {dict}])', 10942 returns = '0|-1', 10943 }, 10944 sign_unplacelist = { 10945 args = 1, 10946 base = 1, 10947 desc = [=[ 10948 Remove previously placed signs from one or more buffers. This 10949 is similar to the |sign_unplace()| function. 10950 10951 The {list} argument specifies the List of signs to remove. 10952 Each list item is a dict with the following sign attributes: 10953 buffer buffer name or number. For the accepted 10954 values, see |bufname()|. If not specified, 10955 then the specified sign is removed from all 10956 the buffers. 10957 group sign group name. If not specified or set to an 10958 empty string, then the global sign group is 10959 used. If set to "*", then all the groups 10960 including the global group are used. 10961 id sign identifier. If not specified, then all 10962 the signs in the specified group are removed. 10963 10964 Returns a List where an entry is set to 0 if the corresponding 10965 sign was successfully removed or -1 on failure. 10966 10967 Example: >vim 10968 " Remove sign with id 10 from buffer a.vim and sign 10969 " with id 20 from buffer b.vim 10970 call sign_unplacelist([ 10971 \ {'id' : 10, 'buffer' : "a.vim"}, 10972 \ {'id' : 20, 'buffer' : 'b.vim'}, 10973 \ ]) 10974 < 10975 ]=], 10976 name = 'sign_unplacelist', 10977 params = { { 'list', 'vim.fn.sign_unplacelist.list.item' } }, 10978 signature = 'sign_unplacelist({list})', 10979 returns = '(0|-1)[]', 10980 }, 10981 simplify = { 10982 args = 1, 10983 base = 1, 10984 desc = [=[ 10985 Simplify the file name as much as possible without changing 10986 the meaning. Shortcuts (on MS-Windows) or symbolic links (on 10987 Unix) are not resolved. If the first path component in 10988 {filename} designates the current directory, this will be 10989 valid for the result as well. A trailing path separator is 10990 not removed either. On Unix "//path" is unchanged, but 10991 "///path" is simplified to "/path" (this follows the Posix 10992 standard). 10993 Example: >vim 10994 simplify("./dir/.././/file/") == "./file/" 10995 <Note: The combination "dir/.." is only removed if "dir" is 10996 a searchable directory or does not exist. On Unix, it is also 10997 removed when "dir" is a symbolic link within the same 10998 directory. In order to resolve all the involved symbolic 10999 links before simplifying the path name, use |resolve()|. 11000 11001 ]=], 11002 name = 'simplify', 11003 params = { { 'filename', 'string' } }, 11004 returns = 'string', 11005 signature = 'simplify({filename})', 11006 }, 11007 sin = { 11008 args = 1, 11009 base = 1, 11010 desc = [=[ 11011 Return the sine of {expr}, measured in radians, as a |Float|. 11012 {expr} must evaluate to a |Float| or a |Number|. 11013 Returns 0.0 if {expr} is not a |Float| or a |Number|. 11014 Examples: >vim 11015 echo sin(100) 11016 < -0.506366 >vim 11017 echo sin(-4.01) 11018 < 0.763301 11019 11020 ]=], 11021 float_func = 'sin', 11022 name = 'sin', 11023 params = { { 'expr', 'number' } }, 11024 returns = 'number', 11025 signature = 'sin({expr})', 11026 }, 11027 sinh = { 11028 args = 1, 11029 base = 1, 11030 desc = [=[ 11031 Return the hyperbolic sine of {expr} as a |Float| in the range 11032 [-inf, inf]. 11033 {expr} must evaluate to a |Float| or a |Number|. 11034 Returns 0.0 if {expr} is not a |Float| or a |Number|. 11035 Examples: >vim 11036 echo sinh(0.5) 11037 < 0.521095 >vim 11038 echo sinh(-0.9) 11039 < -1.026517 11040 11041 ]=], 11042 float_func = 'sinh', 11043 name = 'sinh', 11044 params = { { 'expr', 'number' } }, 11045 signature = 'sinh({expr})', 11046 }, 11047 slice = { 11048 args = { 2, 3 }, 11049 base = 1, 11050 desc = [=[ 11051 Similar to using a |slice| "expr[start : end]", but "end" is 11052 used exclusive. And for a string the indexes are used as 11053 character indexes instead of byte indexes. 11054 Also, composing characters are treated as a part of the 11055 preceding base character. 11056 When {end} is omitted the slice continues to the last item. 11057 When {end} is -1 the last item is omitted. 11058 Returns an empty value if {start} or {end} are invalid. 11059 11060 ]=], 11061 name = 'slice', 11062 params = { { 'expr', 'any' }, { 'start', 'integer' }, { 'end', 'integer' } }, 11063 signature = 'slice({expr}, {start} [, {end}])', 11064 }, 11065 sockconnect = { 11066 args = { 2, 3 }, 11067 desc = [=[ 11068 Connect a socket to an address. If {mode} is "pipe" then 11069 {address} should be the path of a local domain socket (on 11070 unix) or named pipe (on Windows). If {mode} is "tcp" then 11071 {address} should be of the form "host:port" where the host 11072 should be an ip address or host name, and port the port 11073 number. 11074 11075 For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see 11076 |luv-tcp-handle|. 11077 11078 Returns a |channel| ID. Close the socket with |chanclose()|. 11079 Use |chansend()| to send data over a bytes socket, and 11080 |rpcrequest()| and |rpcnotify()| to communicate with a RPC 11081 socket. 11082 11083 {opts} is an optional dictionary with these keys: 11084 |on_data| : callback invoked when data was read from socket 11085 data_buffered : read socket data in |channel-buffered| mode. 11086 rpc : If set, |msgpack-rpc| will be used to communicate 11087 over the socket. 11088 Returns: 11089 - The channel ID on success (greater than zero) 11090 - 0 on invalid arguments or connection failure. 11091 ]=], 11092 name = 'sockconnect', 11093 params = { { 'mode', 'string' }, { 'address', 'string' }, { 'opts', 'table' } }, 11094 signature = 'sockconnect({mode}, {address} [, {opts}])', 11095 }, 11096 sort = { 11097 args = { 1, 3 }, 11098 base = 1, 11099 tags = { 'E702' }, 11100 desc = [=[ 11101 Sort the items in {list} in-place. Returns {list}. 11102 11103 If you want a list to remain unmodified make a copy first: >vim 11104 let sortedlist = sort(copy(mylist)) 11105 11106 <When {how} is omitted or is a string, then sort() uses the 11107 string representation of each item to sort on. Numbers sort 11108 after Strings, |Lists| after Numbers. For sorting text in the 11109 current buffer use |:sort|. 11110 11111 When {how} is given and it is 'i' then case is ignored. 11112 For backwards compatibility, the value one can be used to 11113 ignore case. Zero means to not ignore case. 11114 11115 When {how} is given and it is 'l' then the current collation 11116 locale is used for ordering. Implementation details: 11117 strcoll() is used to compare strings. See |:language| to check 11118 or set the collation locale. |v:collate| can also be used to 11119 check the current locale. Sorting using the locale typically 11120 ignores case. Example: >vim 11121 " ö is sorted similarly to o with English locale. 11122 language collate en_US.UTF8 11123 echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l') 11124 < ['n', 'o', 'O', 'ö', 'p', 'z'] ~ 11125 >vim 11126 " ö is sorted after z with Swedish locale. 11127 language collate sv_SE.UTF8 11128 echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l') 11129 < ['n', 'o', 'O', 'p', 'z', 'ö'] ~ 11130 This does not work properly on Mac. 11131 11132 When {how} is given and it is 'n' then all items will be 11133 sorted numerical (Implementation detail: this uses the 11134 strtod() function to parse numbers, Strings, Lists, Dicts and 11135 Funcrefs will be considered as being 0). 11136 11137 When {how} is given and it is 'N' then all items will be 11138 sorted numerical. This is like 'n' but a string containing 11139 digits will be used as the number they represent. 11140 11141 When {how} is given and it is 'f' then all items will be 11142 sorted numerical. All values must be a Number or a Float. 11143 11144 When {how} is a |Funcref| or a function name, this function 11145 is called to compare items. The function is invoked with two 11146 items as argument and must return zero if they are equal, 1 or 11147 bigger if the first one sorts after the second one, -1 or 11148 smaller if the first one sorts before the second one. 11149 11150 {dict} is for functions with the "dict" attribute. It will be 11151 used to set the local variable "self". |Dictionary-function| 11152 11153 The sort is stable, items which compare equal (as number or as 11154 string) will keep their relative position. E.g., when sorting 11155 on numbers, text strings will sort next to each other, in the 11156 same order as they were originally. 11157 11158 11159 Example: >vim 11160 func MyCompare(i1, i2) 11161 return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1 11162 endfunc 11163 eval mylist->sort("MyCompare") 11164 <A shorter compare version for this specific simple case, which 11165 ignores overflow: >vim 11166 func MyCompare(i1, i2) 11167 return a:i1 - a:i2 11168 endfunc 11169 <For a simple expression you can use a lambda: >vim 11170 eval mylist->sort({i1, i2 -> i1 - i2}) 11171 < 11172 ]=], 11173 name = 'sort', 11174 generics = { 'T' }, 11175 params = { { 'list', 'T[]' }, { 'how', 'string|function' }, { 'dict', 'any' } }, 11176 returns = 'T[]', 11177 signature = 'sort({list} [, {how} [, {dict}]])', 11178 }, 11179 soundfold = { 11180 args = 1, 11181 base = 1, 11182 desc = [=[ 11183 Return the sound-folded equivalent of {word}. Uses the first 11184 language in 'spelllang' for the current window that supports 11185 soundfolding. 'spell' must be set. When no sound folding is 11186 possible the {word} is returned unmodified. 11187 This can be used for making spelling suggestions. Note that 11188 the method can be quite slow. 11189 11190 ]=], 11191 name = 'soundfold', 11192 params = { { 'word', 'string' } }, 11193 returns = 'string', 11194 signature = 'soundfold({word})', 11195 }, 11196 spellbadword = { 11197 args = { 0, 1 }, 11198 base = 1, 11199 desc = [=[ 11200 Without argument: The result is the badly spelled word under 11201 or after the cursor. The cursor is moved to the start of the 11202 bad word. When no bad word is found in the cursor line the 11203 result is an empty string and the cursor doesn't move. 11204 11205 With argument: The result is the first word in {sentence} that 11206 is badly spelled. If there are no spelling mistakes the 11207 result is an empty string. 11208 11209 The return value is a list with two items: 11210 - The badly spelled word or an empty string. 11211 - The type of the spelling error: 11212 "bad" spelling mistake 11213 "rare" rare word 11214 "local" word only valid in another region 11215 "caps" word should start with Capital 11216 Example: >vim 11217 echo spellbadword("the quik brown fox") 11218 < ['quik', 'bad'] ~ 11219 11220 The spelling information for the current window and the value 11221 of 'spelllang' are used. 11222 11223 ]=], 11224 name = 'spellbadword', 11225 params = { { 'sentence', 'string' } }, 11226 signature = 'spellbadword([{sentence}])', 11227 }, 11228 spellsuggest = { 11229 args = { 1, 3 }, 11230 base = 1, 11231 desc = [=[ 11232 Return a |List| with spelling suggestions to replace {word}. 11233 When {max} is given up to this number of suggestions are 11234 returned. Otherwise up to 25 suggestions are returned. 11235 11236 When the {capital} argument is given and it's non-zero only 11237 suggestions with a leading capital will be given. Use this 11238 after a match with 'spellcapcheck'. 11239 11240 {word} can be a badly spelled word followed by other text. 11241 This allows for joining two words that were split. The 11242 suggestions also include the following text, thus you can 11243 replace a line. 11244 11245 {word} may also be a good word. Similar words will then be 11246 returned. {word} itself is not included in the suggestions, 11247 although it may appear capitalized. 11248 11249 The spelling information for the current window is used. The 11250 values of 'spelllang' and 'spellsuggest' are used. 11251 11252 ]=], 11253 name = 'spellsuggest', 11254 params = { { 'word', 'string' }, { 'max', 'integer' }, { 'capital', 'boolean' } }, 11255 returns = 'string[]', 11256 signature = 'spellsuggest({word} [, {max} [, {capital}]])', 11257 }, 11258 split = { 11259 args = { 1, 3 }, 11260 base = 1, 11261 desc = [=[ 11262 Make a |List| out of {string}. When {pattern} is omitted or 11263 empty each white space separated sequence of characters 11264 becomes an item. 11265 Otherwise the string is split where {pattern} matches, 11266 removing the matched characters. 'ignorecase' is not used 11267 here, add \c to ignore case. |/\c| 11268 When the first or last item is empty it is omitted, unless the 11269 {keepempty} argument is given and it's non-zero. 11270 Other empty items are kept when {pattern} matches at least one 11271 character or when {keepempty} is non-zero. 11272 Example: >vim 11273 let words = split(getline('.'), '\W\+') 11274 <To split a string in individual characters: >vim 11275 for c in split(mystring, '\zs') | endfor 11276 <If you want to keep the separator you can also use '\zs' at 11277 the end of the pattern: >vim 11278 echo split('abc:def:ghi', ':\zs') 11279 < > 11280 ['abc:', 'def:', 'ghi'] 11281 < 11282 Splitting a table where the first element can be empty: >vim 11283 let items = split(line, ':', 1) 11284 <The opposite function is |join()|. 11285 11286 ]=], 11287 name = 'split', 11288 params = { { 'string', 'string' }, { 'pattern', 'string' }, { 'keepempty', 'boolean' } }, 11289 returns = 'string[]', 11290 signature = 'split({string} [, {pattern} [, {keepempty}]])', 11291 }, 11292 sqrt = { 11293 args = 1, 11294 base = 1, 11295 desc = [=[ 11296 Return the non-negative square root of Float {expr} as a 11297 |Float|. 11298 {expr} must evaluate to a |Float| or a |Number|. When {expr} 11299 is negative the result is NaN (Not a Number). Returns 0.0 if 11300 {expr} is not a |Float| or a |Number|. 11301 Examples: >vim 11302 echo sqrt(100) 11303 < 10.0 >vim 11304 echo sqrt(-4.01) 11305 < str2float("nan") 11306 NaN may be different, it depends on system libraries. 11307 11308 ]=], 11309 float_func = 'sqrt', 11310 name = 'sqrt', 11311 params = { { 'expr', 'number' } }, 11312 signature = 'sqrt({expr})', 11313 }, 11314 srand = { 11315 args = { 0, 1 }, 11316 base = 1, 11317 desc = [=[ 11318 Initialize seed used by |rand()|: 11319 - If {expr} is not given, seed values are initialized by 11320 reading from /dev/urandom, if possible, or using time(NULL) 11321 a.k.a. epoch time otherwise; this only has second accuracy. 11322 - If {expr} is given it must be a Number. It is used to 11323 initialize the seed values. This is useful for testing or 11324 when a predictable sequence is intended. 11325 11326 Examples: >vim 11327 let seed = srand() 11328 let seed = srand(userinput) 11329 echo rand(seed) 11330 < 11331 ]=], 11332 name = 'srand', 11333 params = { { 'expr', 'number' } }, 11334 signature = 'srand([{expr}])', 11335 }, 11336 state = { 11337 args = { 0, 1 }, 11338 base = 1, 11339 desc = [=[ 11340 Return a string which contains characters indicating the 11341 current state. Mostly useful in callbacks that want to do 11342 work that may not always be safe. Roughly this works like: 11343 - callback uses state() to check if work is safe to do. 11344 Yes: then do it right away. 11345 No: add to work queue and add a |SafeState| autocommand. 11346 - When SafeState is triggered and executes your autocommand, 11347 check with `state()` if the work can be done now, and if yes 11348 remove it from the queue and execute. 11349 Remove the autocommand if the queue is now empty. 11350 Also see |mode()|. 11351 11352 When {what} is given only characters in this string will be 11353 added. E.g, this checks if the screen has scrolled: >vim 11354 if state('s') == '' 11355 " screen has not scrolled 11356 < 11357 These characters indicate the state, generally indicating that 11358 something is busy: 11359 m halfway a mapping, :normal command, |feedkeys()| or 11360 stuffed command 11361 o operator pending, e.g. after |d| 11362 a Insert mode autocomplete active 11363 x executing an autocommand 11364 S not triggering SafeState, e.g. after |f| or a count 11365 c callback invoked, including timer (repeats for 11366 recursiveness up to "ccc") 11367 s screen has scrolled for messages 11368 ]=], 11369 fast = true, 11370 name = 'state', 11371 params = { { 'what', 'string' } }, 11372 signature = 'state([{what}])', 11373 }, 11374 stdioopen = { 11375 args = 1, 11376 desc = [=[ 11377 With |--headless| this opens stdin and stdout as a |channel|. 11378 May be called only once. See |channel-stdio|. stderr is not 11379 handled by this function, see |v:stderr|. 11380 11381 Close the stdio handles with |chanclose()|. Use |chansend()| 11382 to send data to stdout, and |rpcrequest()| and |rpcnotify()| 11383 to communicate over RPC. 11384 11385 {opts} is a dictionary with these keys: 11386 |on_stdin| : callback invoked when stdin is written to. 11387 on_print : callback invoked when Nvim needs to print a 11388 message, with the message (whose type is string) 11389 as sole argument. 11390 stdin_buffered : read stdin in |channel-buffered| mode. 11391 rpc : If set, |msgpack-rpc| will be used to communicate 11392 over stdio 11393 Returns: 11394 - |channel-id| on success (value is always 1) 11395 - 0 on invalid arguments 11396 ]=], 11397 name = 'stdioopen', 11398 params = { { 'opts', 'table' } }, 11399 signature = 'stdioopen({opts})', 11400 }, 11401 stdpath = { 11402 args = 1, 11403 tags = { 'E6100' }, 11404 desc = [=[ 11405 Returns |standard-path| locations of various default files and 11406 directories. The locations are driven by |base-directories| 11407 which you can configure via |$NVIM_APPNAME| or the `$XDG_…` 11408 environment variables. 11409 11410 {what} Type Description ~ 11411 cache String Cache directory: arbitrary temporary 11412 storage for plugins, etc. 11413 config String User configuration directory. |init.vim| 11414 is stored here. 11415 config_dirs List Other configuration directories. 11416 data String User data directory. 11417 data_dirs List Other data directories. 11418 log String Logs directory (for use by plugins too). 11419 run String Run directory: temporary, local storage 11420 for sockets, named pipes, etc. 11421 state String Session state: storage for backupdir, 11422 file drafts, |shada|, swap, undo, 'viewdir'. 11423 11424 Example: >vim 11425 echo stdpath("config") 11426 < 11427 ]=], 11428 fast = true, 11429 name = 'stdpath', 11430 params = { { 'what', "'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'" } }, 11431 returns = 'string|string[]', 11432 signature = 'stdpath({what})', 11433 }, 11434 stdpath__1 = { 11435 args = 1, 11436 fast = true, 11437 name = 'stdpath', 11438 params = { { 'what', "'cache'|'config'|'data'|'log'|'run'|'state'" } }, 11439 returns = 'string', 11440 }, 11441 stdpath__2 = { 11442 args = 1, 11443 fast = true, 11444 name = 'stdpath', 11445 params = { { 'what', "'config_dirs'|'data_dirs'" } }, 11446 returns = 'string[]', 11447 }, 11448 str2float = { 11449 args = 1, 11450 base = 1, 11451 desc = [=[ 11452 Convert String {string} to a Float. This mostly works the 11453 same as when using a floating point number in an expression, 11454 see |floating-point-format|. But it's a bit more permissive. 11455 E.g., "1e40" is accepted, while in an expression you need to 11456 write "1.0e40". The hexadecimal form "0x123" is also 11457 accepted, but not others, like binary or octal. 11458 When {quoted} is present and non-zero then embedded single 11459 quotes before the dot are ignored, thus "1'000.0" is a 11460 thousand. 11461 Text after the number is silently ignored. 11462 The decimal point is always '.', no matter what the locale is 11463 set to. A comma ends the number: "12,345.67" is converted to 11464 12.0. You can strip out thousands separators with 11465 |substitute()|: >vim 11466 let f = str2float(substitute(text, ',', '', 'g')) 11467 < 11468 Returns 0.0 if the conversion fails. 11469 11470 ]=], 11471 name = 'str2float', 11472 params = { { 'string', 'string' }, { 'quoted', 'boolean' } }, 11473 signature = 'str2float({string} [, {quoted}])', 11474 }, 11475 str2list = { 11476 args = { 1, 2 }, 11477 base = 1, 11478 desc = [=[ 11479 Return a list containing the number values which represent 11480 each character in String {string}. Examples: >vim 11481 echo str2list(" ") " returns [32] 11482 echo str2list("ABC") " returns [65, 66, 67] 11483 <|list2str()| does the opposite. 11484 11485 UTF-8 encoding is always used, {utf8} option has no effect, 11486 and exists only for backwards-compatibility. 11487 With UTF-8 composing characters are handled properly: >vim 11488 echo str2list("á") " returns [97, 769] 11489 < 11490 ]=], 11491 name = 'str2list', 11492 params = { { 'string', 'string' }, { 'utf8', 'boolean' } }, 11493 signature = 'str2list({string} [, {utf8}])', 11494 }, 11495 str2nr = { 11496 args = { 1, 3 }, 11497 base = 1, 11498 desc = [=[ 11499 Convert string {string} to a number. 11500 {base} is the conversion base, it can be 2, 8, 10 or 16. 11501 When {quoted} is present and non-zero then embedded single 11502 quotes are ignored, thus "1'000'000" is a million. 11503 11504 When {base} is omitted base 10 is used. This also means that 11505 a leading zero doesn't cause octal conversion to be used, as 11506 with the default String to Number conversion. Example: >vim 11507 let nr = str2nr('0123') 11508 < 11509 When {base} is 16 a leading "0x" or "0X" is ignored. With a 11510 different base the result will be zero. Similarly, when 11511 {base} is 8 a leading "0", "0o" or "0O" is ignored, and when 11512 {base} is 2 a leading "0b" or "0B" is ignored. 11513 Text after the number is silently ignored. 11514 11515 Returns 0 if {string} is empty or on error. 11516 11517 ]=], 11518 name = 'str2nr', 11519 params = { { 'string', 'string' }, { 'base', 'integer' } }, 11520 signature = 'str2nr({string} [, {base}])', 11521 }, 11522 strcharlen = { 11523 args = 1, 11524 base = 1, 11525 desc = [=[ 11526 The result is a Number, which is the number of characters 11527 in String {string}. Composing characters are ignored. 11528 |strchars()| can count the number of characters, counting 11529 composing characters separately. 11530 11531 Returns 0 if {string} is empty or on error. 11532 11533 Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. 11534 11535 ]=], 11536 name = 'strcharlen', 11537 params = { { 'string', 'string' } }, 11538 returns = 'integer', 11539 signature = 'strcharlen({string})', 11540 }, 11541 strcharpart = { 11542 args = { 2, 4 }, 11543 base = 1, 11544 desc = [=[ 11545 Like |strpart()| but using character index and length instead 11546 of byte index and length. 11547 When {skipcc} is omitted or zero, composing characters are 11548 counted separately. 11549 When {skipcc} set to 1, composing characters are treated as a 11550 part of the preceding base character, similar to |slice()|. 11551 When a character index is used where a character does not 11552 exist it is omitted and counted as one character. For 11553 example: >vim 11554 echo strcharpart('abc', -1, 2) 11555 <results in 'a'. 11556 11557 Returns an empty string on error. 11558 11559 ]=], 11560 fast = true, 11561 name = 'strcharpart', 11562 params = { 11563 { 'src', 'string' }, 11564 { 'start', 'integer' }, 11565 { 'len', 'integer' }, 11566 { 'skipcc', '0|1|boolean' }, 11567 }, 11568 returns = 'string', 11569 signature = 'strcharpart({src}, {start} [, {len} [, {skipcc}]])', 11570 }, 11571 strchars = { 11572 args = { 1, 2 }, 11573 base = 1, 11574 desc = [=[ 11575 The result is a Number, which is the number of characters 11576 in String {string}. 11577 When {skipcc} is omitted or zero, composing characters are 11578 counted separately. 11579 When {skipcc} set to 1, composing characters are ignored. 11580 |strcharlen()| always does this. 11581 11582 Returns zero on error. 11583 11584 Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. 11585 11586 {skipcc} is only available after 7.4.755. For backward 11587 compatibility, you can define a wrapper function: >vim 11588 if has("patch-7.4.755") 11589 function s:strchars(str, skipcc) 11590 return strchars(a:str, a:skipcc) 11591 endfunction 11592 else 11593 function s:strchars(str, skipcc) 11594 if a:skipcc 11595 return strlen(substitute(a:str, ".", "x", "g")) 11596 else 11597 return strchars(a:str) 11598 endif 11599 endfunction 11600 endif 11601 < 11602 ]=], 11603 name = 'strchars', 11604 params = { { 'string', 'string' }, { 'skipcc', '0|1|boolean' } }, 11605 returns = 'integer', 11606 signature = 'strchars({string} [, {skipcc}])', 11607 }, 11608 strdisplaywidth = { 11609 args = { 1, 2 }, 11610 base = 1, 11611 desc = [=[ 11612 The result is a Number, which is the number of display cells 11613 String {string} occupies on the screen when it starts at {col} 11614 (first column is zero). When {col} is omitted zero is used. 11615 Otherwise it is the screen column where to start. This 11616 matters for Tab characters. 11617 The option settings of the current window are used. This 11618 matters for anything that's displayed differently, such as 11619 'tabstop' and 'display'. 11620 When {string} contains characters with East Asian Width Class 11621 Ambiguous, this function's return value depends on 11622 'ambiwidth'. 11623 Returns zero on error. 11624 Also see |strlen()|, |strwidth()| and |strchars()|. 11625 11626 ]=], 11627 name = 'strdisplaywidth', 11628 params = { { 'string', 'string' }, { 'col', 'integer' } }, 11629 returns = 'integer', 11630 signature = 'strdisplaywidth({string} [, {col}])', 11631 }, 11632 strftime = { 11633 args = { 1, 2 }, 11634 base = 1, 11635 desc = [=[ 11636 The result is a String, which is a formatted date and time, as 11637 specified by the {format} string. The given {time} is used, 11638 or the current time if no time is given. The accepted 11639 {format} depends on your system, thus this is not portable! 11640 See the manual page of the C function strftime() for the 11641 format. The maximum length of the result is 80 characters. 11642 See also |localtime()|, |getftime()| and |strptime()|. 11643 The language can be changed with the |:language| command. 11644 Examples: >vim 11645 echo strftime("%c") " Sun Apr 27 11:49:23 1997 11646 echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25 11647 echo strftime("%y%m%d %T") " 970427 11:53:55 11648 echo strftime("%H:%M") " 11:55 11649 echo strftime("%c", getftime("file.c")) 11650 " Show mod time of file.c. 11651 < 11652 ]=], 11653 name = 'strftime', 11654 params = { { 'format', 'string' }, { 'time', 'number' } }, 11655 returns = 'string', 11656 signature = 'strftime({format} [, {time}])', 11657 }, 11658 strgetchar = { 11659 args = 2, 11660 base = 1, 11661 desc = [=[ 11662 Get a Number corresponding to the character at {index} in 11663 {str}. This uses a zero-based character index, not a byte 11664 index. Composing characters are considered separate 11665 characters here. Use |nr2char()| to convert the Number to a 11666 String. 11667 Returns -1 if {index} is invalid. 11668 Also see |strcharpart()| and |strchars()|. 11669 11670 ]=], 11671 name = 'strgetchar', 11672 params = { { 'str', 'string' }, { 'index', 'integer' } }, 11673 returns = 'integer', 11674 signature = 'strgetchar({str}, {index})', 11675 }, 11676 stridx = { 11677 args = { 2, 3 }, 11678 base = 1, 11679 desc = [=[ 11680 The result is a Number, which gives the byte index in 11681 {haystack} of the first occurrence of the String {needle}. 11682 If {start} is specified, the search starts at index {start}. 11683 This can be used to find a second match: >vim 11684 let colon1 = stridx(line, ":") 11685 let colon2 = stridx(line, ":", colon1 + 1) 11686 <The search is done case-sensitive. 11687 For pattern searches use |match()|. 11688 -1 is returned if the {needle} does not occur in {haystack}. 11689 See also |strridx()|. 11690 Examples: >vim 11691 echo stridx("An Example", "Example") " 3 11692 echo stridx("Starting point", "Start") " 0 11693 echo stridx("Starting point", "start") " -1 11694 < *strstr()* *strchr()* 11695 stridx() works similar to the C function strstr(). When used 11696 with a single character it works similar to strchr(). 11697 11698 ]=], 11699 fast = true, 11700 name = 'stridx', 11701 params = { { 'haystack', 'string' }, { 'needle', 'string' }, { 'start', 'integer' } }, 11702 returns = 'integer', 11703 signature = 'stridx({haystack}, {needle} [, {start}])', 11704 }, 11705 string = { 11706 args = 1, 11707 base = 1, 11708 desc = [=[ 11709 Return {expr} converted to a String. If {expr} is a Number, 11710 Float, String, Blob or a composition of them, then the result 11711 can be parsed back with |eval()|. 11712 {expr} type result ~ 11713 String 'string' 11714 Number 123 11715 Float 123.123456 or 1.123456e8 or 11716 `str2float('inf')` 11717 Funcref `function('name')` 11718 Blob 0z00112233.44556677.8899 11719 List [item, item] 11720 Dictionary `{key: value, key: value}` 11721 Note that in String values the ' character is doubled. 11722 Also see |strtrans()|. 11723 Note 2: Output format is mostly compatible with YAML, except 11724 for infinite and NaN floating-point values representations 11725 which use |str2float()|. Strings are also dumped literally, 11726 only single quote is escaped, which does not allow using YAML 11727 for parsing back binary strings. |eval()| should always work 11728 for strings and floats though, and this is the only official 11729 method. Use |msgpackdump()| or |json_encode()| if you need to 11730 share data with other applications. 11731 11732 ]=], 11733 name = 'string', 11734 params = { { 'expr', 'any' } }, 11735 returns = 'string', 11736 signature = 'string({expr})', 11737 }, 11738 strlen = { 11739 args = 1, 11740 base = 1, 11741 desc = [=[ 11742 The result is a Number, which is the length of the String 11743 {string} in bytes. 11744 If the argument is a Number it is first converted to a String. 11745 For other types an error is given and zero is returned. 11746 If you want to count the number of multibyte characters use 11747 |strchars()|. 11748 Also see |len()|, |strdisplaywidth()| and |strwidth()|. 11749 11750 ]=], 11751 name = 'strlen', 11752 params = { { 'string', 'string' } }, 11753 returns = 'integer', 11754 signature = 'strlen({string})', 11755 }, 11756 strpart = { 11757 args = { 2, 4 }, 11758 base = 1, 11759 desc = [=[ 11760 The result is a String, which is part of {src}, starting from 11761 byte {start}, with the byte length {len}. 11762 When {chars} is present and TRUE then {len} is the number of 11763 characters positions (composing characters are not counted 11764 separately, thus "1" means one base character and any 11765 following composing characters). 11766 To count {start} as characters instead of bytes use 11767 |strcharpart()|. 11768 11769 When bytes are selected which do not exist, this doesn't 11770 result in an error, the bytes are simply omitted. 11771 If {len} is missing, the copy continues from {start} till the 11772 end of the {src}. >vim 11773 echo strpart("abcdefg", 3, 2) " returns 'de' 11774 echo strpart("abcdefg", -2, 4) " returns 'ab' 11775 echo strpart("abcdefg", 5, 4) " returns 'fg' 11776 echo strpart("abcdefg", 3) " returns 'defg' 11777 11778 <Note: To get the first character, {start} must be 0. For 11779 example, to get the character under the cursor: >vim 11780 strpart(getline("."), col(".") - 1, 1, v:true) 11781 < 11782 Returns an empty string on error. 11783 11784 ]=], 11785 fast = true, 11786 name = 'strpart', 11787 params = { 11788 { 'src', 'string' }, 11789 { 'start', 'integer' }, 11790 { 'len', 'integer' }, 11791 { 'chars', '0|1' }, 11792 }, 11793 returns = 'string', 11794 signature = 'strpart({src}, {start} [, {len} [, {chars}]])', 11795 }, 11796 strptime = { 11797 args = 2, 11798 base = 1, 11799 desc = [=[ 11800 The result is a Number, which is a unix timestamp representing 11801 the date and time in {timestring}, which is expected to match 11802 the format specified in {format}. 11803 11804 The accepted {format} depends on your system, thus this is not 11805 portable! See the manual page of the C function strptime() 11806 for the format. Especially avoid "%c". The value of $TZ also 11807 matters. 11808 11809 If the {timestring} cannot be parsed with {format} zero is 11810 returned. If you do not know the format of {timestring} you 11811 can try different {format} values until you get a non-zero 11812 result. 11813 11814 See also |strftime()|. 11815 Examples: >vim 11816 echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23") 11817 < 862156163 >vim 11818 echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55")) 11819 < Sun Apr 27 11:53:55 1997 >vim 11820 echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600) 11821 < Sun Apr 27 12:53:55 1997 11822 11823 ]=], 11824 name = 'strptime', 11825 params = { { 'format', 'string' }, { 'timestring', 'string' } }, 11826 returns = 'integer', 11827 signature = 'strptime({format}, {timestring})', 11828 }, 11829 strridx = { 11830 args = { 2, 3 }, 11831 base = 1, 11832 desc = [=[ 11833 The result is a Number, which gives the byte index in 11834 {haystack} of the last occurrence of the String {needle}. 11835 When {start} is specified, matches beyond this index are 11836 ignored. This can be used to find a match before a previous 11837 match: >vim 11838 let lastcomma = strridx(line, ",") 11839 let comma2 = strridx(line, ",", lastcomma - 1) 11840 <The search is done case-sensitive. 11841 For pattern searches use |match()|. 11842 -1 is returned if the {needle} does not occur in {haystack}. 11843 If the {needle} is empty the length of {haystack} is returned. 11844 See also |stridx()|. Examples: >vim 11845 echo strridx("an angry armadillo", "an") 3 11846 < *strrchr()* 11847 When used with a single character it works similar to the C 11848 function strrchr(). 11849 11850 ]=], 11851 name = 'strridx', 11852 params = { 11853 { 'haystack', 'string' }, 11854 { 'needle', 'string' }, 11855 { 'start', 'integer' }, 11856 }, 11857 returns = 'integer', 11858 signature = 'strridx({haystack}, {needle} [, {start}])', 11859 }, 11860 strtrans = { 11861 args = 1, 11862 base = 1, 11863 desc = [=[ 11864 The result is a String, which is {string} with all unprintable 11865 characters translated into printable characters 'isprint'. 11866 Like they are shown in a window. Example: >vim 11867 echo strtrans(@a) 11868 <This displays a newline in register a as "^@" instead of 11869 starting a new line. 11870 11871 Returns an empty string on error. 11872 11873 ]=], 11874 fast = true, 11875 name = 'strtrans', 11876 params = { { 'string', 'string' } }, 11877 returns = 'string', 11878 signature = 'strtrans({string})', 11879 }, 11880 strutf16len = { 11881 args = { 1, 2 }, 11882 base = 1, 11883 desc = [=[ 11884 The result is a Number, which is the number of UTF-16 code 11885 units in String {string} (after converting it to UTF-16). 11886 11887 When {countcc} is TRUE, composing characters are counted 11888 separately. 11889 When {countcc} is omitted or FALSE, composing characters are 11890 ignored. 11891 11892 Returns zero on error. 11893 11894 Also see |strlen()| and |strcharlen()|. 11895 Examples: >vim 11896 echo strutf16len('a') " returns 1 11897 echo strutf16len('©') " returns 1 11898 echo strutf16len('😊') " returns 2 11899 echo strutf16len('ą́') " returns 1 11900 echo strutf16len('ą́', v:true) " returns 3 11901 < 11902 ]=], 11903 name = 'strutf16len', 11904 params = { { 'string', 'string' }, { 'countcc', '0|1' } }, 11905 returns = 'integer', 11906 signature = 'strutf16len({string} [, {countcc}])', 11907 }, 11908 strwidth = { 11909 args = 1, 11910 base = 1, 11911 desc = [=[ 11912 The result is a Number, which is the number of display cells 11913 String {string} occupies. A Tab character is counted as one 11914 cell, alternatively use |strdisplaywidth()|. 11915 When {string} contains characters with East Asian Width Class 11916 Ambiguous, this function's return value depends on 11917 'ambiwidth'. 11918 Returns zero on error. 11919 Also see |strlen()|, |strdisplaywidth()| and |strchars()|. 11920 11921 ]=], 11922 fast = true, 11923 name = 'strwidth', 11924 params = { { 'string', 'string' } }, 11925 returns = 'integer', 11926 signature = 'strwidth({string})', 11927 }, 11928 submatch = { 11929 args = { 1, 2 }, 11930 base = 1, 11931 tags = { 'E935' }, 11932 desc = [=[ 11933 Only for an expression in a |:substitute| command or 11934 |substitute()| function. 11935 Returns the {nr}th submatch of the matched text. When {nr} 11936 is 0 the whole matched text is returned. 11937 Note that a NL in the string can stand for a line break of a 11938 multi-line match or a NUL character in the text. 11939 Also see |sub-replace-expression|. 11940 11941 If {list} is present and non-zero then submatch() returns 11942 a list of strings, similar to |getline()| with two arguments. 11943 NL characters in the text represent NUL characters in the 11944 text. 11945 Only returns more than one item for |:substitute|, inside 11946 |substitute()| this list will always contain one or zero 11947 items, since there are no real line breaks. 11948 11949 When |substitute()| is used recursively only the submatches in 11950 the current (deepest) call can be obtained. 11951 11952 Returns an empty string or list on error. 11953 11954 Examples: >vim 11955 s/\d\+/\=submatch(0) + 1/ 11956 echo substitute(text, '\d\+', '\=submatch(0) + 1', '') 11957 <This finds the first number in the line and adds one to it. 11958 A line break is included as a newline character. 11959 11960 ]=], 11961 name = 'submatch', 11962 params = { { 'nr', 'integer' }, { 'list', 'nil' } }, 11963 signature = 'submatch({nr} [, {list}])', 11964 returns = 'string', 11965 }, 11966 submatch__1 = { 11967 args = { 2 }, 11968 base = 1, 11969 name = 'submatch', 11970 params = { { 'nr', 'integer' }, { 'list', 'integer' } }, 11971 returns = 'string|string[]', 11972 }, 11973 substitute = { 11974 args = 4, 11975 base = 1, 11976 desc = [=[ 11977 The result is a String, which is a copy of {string}, in which 11978 the first match of {pat} is replaced with {sub}. 11979 When {flags} is "g", all matches of {pat} in {string} are 11980 replaced. Otherwise {flags} should be "". 11981 11982 This works like the ":substitute" command (without any flags). 11983 But the matching with {pat} is always done like the 'magic' 11984 option is set and 'cpoptions' is empty (to make scripts 11985 portable). 'ignorecase' is still relevant, use |/\c| or |/\C| 11986 if you want to ignore or match case and ignore 'ignorecase'. 11987 'smartcase' is not used. See |string-match| for how {pat} is 11988 used. 11989 11990 A "~" in {sub} is not replaced with the previous {sub}. 11991 Note that some codes in {sub} have a special meaning 11992 |sub-replace-special|. For example, to replace something with 11993 "\n" (two characters), use "\\\\n" or '\\n'. 11994 11995 When {pat} does not match in {string}, {string} is returned 11996 unmodified. 11997 11998 Example: >vim 11999 let &path = substitute(&path, ",\\=[^,]*$", "", "") 12000 <This removes the last component of the 'path' option. >vim 12001 echo substitute("testing", ".*", "\\U\\0", "") 12002 <results in "TESTING". 12003 12004 When {sub} starts with "\=", the remainder is interpreted as 12005 an expression. See |sub-replace-expression|. Example: >vim 12006 echo substitute(s, '%\(\x\x\)', 12007 \ '\=nr2char("0x" .. submatch(1))', 'g') 12008 12009 <When {sub} is a Funcref that function is called, with one 12010 optional argument. Example: >vim 12011 echo substitute(s, '%\(\x\x\)', SubNr, 'g') 12012 <The optional argument is a list which contains the whole 12013 matched string and up to nine submatches, like what 12014 |submatch()| returns. Example: >vim 12015 echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g') 12016 12017 <Returns an empty string on error. 12018 12019 ]=], 12020 name = 'substitute', 12021 params = { 12022 { 'string', 'string' }, 12023 { 'pat', 'string' }, 12024 { 'sub', 'string' }, 12025 { 'flags', 'string' }, 12026 }, 12027 returns = 'string', 12028 signature = 'substitute({string}, {pat}, {sub}, {flags})', 12029 }, 12030 swapfilelist = { 12031 desc = [=[ 12032 Returns a list of swap file names, like what "vim -r" shows. 12033 See the |-r| command argument. The 'directory' option is used 12034 for the directories to inspect. If you only want to get a 12035 list of swap files in the current directory then temporarily 12036 set 'directory' to a dot: >vim 12037 let save_dir = &directory 12038 let &directory = '.' 12039 let swapfiles = swapfilelist() 12040 let &directory = save_dir 12041 < 12042 ]=], 12043 name = 'swapfilelist', 12044 params = {}, 12045 returns = 'string[]', 12046 signature = 'swapfilelist()', 12047 }, 12048 swapinfo = { 12049 args = 1, 12050 base = 1, 12051 desc = [=[ 12052 The result is a dictionary, which holds information about the 12053 swapfile {fname}. The available fields are: 12054 version Vim version 12055 user user name 12056 host host name 12057 fname original file name 12058 pid PID of the Nvim process that created the swap 12059 file, or zero if not running. 12060 mtime last modification time in seconds 12061 inode Optional: INODE number of the file 12062 dirty 1 if file was modified, 0 if not 12063 In case of failure an "error" item is added with the reason: 12064 Cannot open file: file not found or in accessible 12065 Cannot read file: cannot read first block 12066 Not a swap file: does not contain correct block ID 12067 Magic number mismatch: Info in first block is invalid 12068 12069 ]=], 12070 name = 'swapinfo', 12071 params = { { 'fname', 'string' } }, 12072 signature = 'swapinfo({fname})', 12073 }, 12074 swapname = { 12075 args = 1, 12076 base = 1, 12077 desc = [=[ 12078 The result is the swap file path of the buffer {buf}. 12079 For the use of {buf}, see |bufname()| above. 12080 If buffer {buf} is the current buffer, the result is equal to 12081 |:swapname| (unless there is no swap file). 12082 If buffer {buf} has no swap file, returns an empty string. 12083 12084 ]=], 12085 name = 'swapname', 12086 params = { { 'buf', 'integer|string' } }, 12087 returns = 'string', 12088 signature = 'swapname({buf})', 12089 }, 12090 synID = { 12091 args = 3, 12092 desc = [=[ 12093 The result is a Number, which is the syntax ID at the position 12094 {lnum} and {col} in the current window. 12095 The syntax ID can be used with |synIDattr()| and 12096 |synIDtrans()| to obtain syntax information about text. 12097 12098 {col} is 1 for the leftmost column, {lnum} is 1 for the first 12099 line. 'synmaxcol' applies, in a longer line zero is returned. 12100 Note that when the position is after the last character, 12101 that's where the cursor can be in Insert mode, synID() returns 12102 zero. {lnum} is used like with |getline()|. 12103 12104 When {trans} is |TRUE|, transparent items are reduced to the 12105 item that they reveal. This is useful when wanting to know 12106 the effective color. When {trans} is |FALSE|, the transparent 12107 item is returned. This is useful when wanting to know which 12108 syntax item is effective (e.g. inside parens). 12109 Warning: This function can be very slow. Best speed is 12110 obtained by going through the file in forward direction. 12111 12112 Returns zero on error. 12113 12114 Example (echoes the name of the syntax item under the cursor): >vim 12115 echo synIDattr(synID(line("."), col("."), 1), "name") 12116 < 12117 ]=], 12118 name = 'synID', 12119 params = { { 'lnum', 'integer|string' }, { 'col', 'integer' }, { 'trans', '0|1' } }, 12120 returns = 'integer', 12121 signature = 'synID({lnum}, {col}, {trans})', 12122 }, 12123 synIDattr = { 12124 args = { 2, 3 }, 12125 base = 1, 12126 desc = [=[ 12127 The result is a String, which is the {what} attribute of 12128 syntax ID {synID}. This can be used to obtain information 12129 about a syntax item. 12130 {mode} can be "gui" or "cterm", to get the attributes 12131 for that mode. When {mode} is omitted, or an invalid value is 12132 used, the attributes for the currently active highlighting are 12133 used (GUI or cterm). 12134 Use |synIDtrans()| to follow linked highlight groups. 12135 {what} result 12136 "name" the name of the syntax item 12137 "fg" foreground color (GUI: color name used to set 12138 the color, cterm: color number as a string, 12139 term: empty string) 12140 "bg" background color (as with "fg") 12141 "font" font name (only available in the GUI) 12142 |highlight-font| 12143 "sp" special color (as with "fg") |guisp| 12144 "fg#" like "fg", but for the GUI and the GUI is 12145 running the name in "#RRGGBB" form 12146 "bg#" like "fg#" for "bg" 12147 "sp#" like "fg#" for "sp" 12148 "bold" "1" if bold 12149 "italic" "1" if italic 12150 "reverse" "1" if reverse 12151 "inverse" "1" if inverse (= reverse) 12152 "standout" "1" if standout 12153 "underline" "1" if underlined 12154 "undercurl" "1" if undercurled 12155 "underdouble" "1" if double underlined 12156 "underdotted" "1" if dotted underlined 12157 "underdashed" "1" if dashed underlined 12158 "strikethrough" "1" if struckthrough 12159 "altfont" "1" if alternative font 12160 "nocombine" "1" if nocombine 12161 "dim" "1" if half-bright/dimmed 12162 "blink" "1" if blinking 12163 "conceal" "1" if concealed 12164 "overline" "1" if overlined 12165 12166 Returns an empty string on error. 12167 12168 Example (echoes the color of the syntax item under the 12169 cursor): >vim 12170 echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") 12171 < 12172 Can also be used as a |method|: >vim 12173 echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg") 12174 < 12175 ]=], 12176 name = 'synIDattr', 12177 params = { { 'synID', 'integer' }, { 'what', 'string' }, { 'mode', 'string' } }, 12178 returns = 'string', 12179 signature = 'synIDattr({synID}, {what} [, {mode}])', 12180 }, 12181 synIDtrans = { 12182 args = 1, 12183 base = 1, 12184 desc = [=[ 12185 The result is a Number, which is the translated syntax ID of 12186 {synID}. This is the syntax group ID of what is being used to 12187 highlight the character. Highlight links given with 12188 ":highlight link" are followed. 12189 12190 Returns zero on error. 12191 12192 ]=], 12193 name = 'synIDtrans', 12194 params = { { 'synID', 'integer' } }, 12195 returns = 'integer', 12196 signature = 'synIDtrans({synID})', 12197 }, 12198 synconcealed = { 12199 args = 2, 12200 desc = [=[ 12201 The result is a |List| with three items: 12202 1. The first item in the list is 0 if the character at the 12203 position {lnum} and {col} is not part of a concealable 12204 region, 1 if it is. {lnum} is used like with |getline()|. 12205 2. The second item in the list is a string. If the first item 12206 is 1, the second item contains the text which will be 12207 displayed in place of the concealed text, depending on the 12208 current setting of 'conceallevel' and 'listchars'. 12209 3. The third and final item in the list is a number 12210 representing the specific syntax region matched in the 12211 line. When the character is not concealed the value is 12212 zero. This allows detection of the beginning of a new 12213 concealable region if there are two consecutive regions 12214 with the same replacement character. For an example, if 12215 the text is "123456" and both "23" and "45" are concealed 12216 and replaced by the character "X", then: 12217 call returns ~ 12218 synconcealed(lnum, 1) [0, '', 0] 12219 synconcealed(lnum, 2) [1, 'X', 1] 12220 synconcealed(lnum, 3) [1, 'X', 1] 12221 synconcealed(lnum, 4) [1, 'X', 2] 12222 synconcealed(lnum, 5) [1, 'X', 2] 12223 synconcealed(lnum, 6) [0, '', 0] 12224 12225 Note: Doesn't consider |matchadd()| highlighting items, 12226 since syntax and matching highlighting are two different 12227 mechanisms |syntax-vs-match|. 12228 ]=], 12229 name = 'synconcealed', 12230 params = { { 'lnum', 'integer|string' }, { 'col', 'integer' } }, 12231 returns = '[integer, string, integer]', 12232 signature = 'synconcealed({lnum}, {col})', 12233 }, 12234 synstack = { 12235 args = 2, 12236 desc = [=[ 12237 Return a |List|, which is the stack of syntax items at the 12238 position {lnum} and {col} in the current window. {lnum} is 12239 used like with |getline()|. Each item in the List is an ID 12240 like what |synID()| returns. 12241 The first item in the List is the outer region, following are 12242 items contained in that one. The last one is what |synID()| 12243 returns, unless not the whole item is highlighted or it is a 12244 transparent item. 12245 This function is useful for debugging a syntax file. 12246 Example that shows the syntax stack under the cursor: >vim 12247 for id in synstack(line("."), col(".")) 12248 echo synIDattr(id, "name") 12249 endfor 12250 <When the position specified with {lnum} and {col} is invalid 12251 an empty list is returned. The position just after the last 12252 character in a line and the first column in an empty line are 12253 valid positions. 12254 ]=], 12255 name = 'synstack', 12256 params = { { 'lnum', 'integer|string' }, { 'col', 'integer' } }, 12257 returns = 'integer[]', 12258 signature = 'synstack({lnum}, {col})', 12259 }, 12260 system = { 12261 args = { 1, 2 }, 12262 base = 1, 12263 tags = { 'E677' }, 12264 desc = [=[ 12265 Note: Prefer |vim.system()| in Lua. 12266 12267 Gets the output of {cmd} as a |string| (|systemlist()| returns 12268 a |List|) and sets |v:shell_error| to the error code. 12269 {cmd} is treated as in |jobstart()|: 12270 If {cmd} is a List it runs directly (no 'shell'). 12271 If {cmd} is a String it runs in the 'shell', like this: >vim 12272 call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) 12273 12274 <Not to be used for interactive commands. 12275 12276 Result is a String, filtered to avoid platform-specific quirks: 12277 - <CR><NL> is replaced with <NL> 12278 - NUL characters are replaced with SOH (0x01) 12279 12280 Example: >vim 12281 echo system(['ls', expand('%:h')]) 12282 12283 <If {input} is a string it is written to a pipe and passed as 12284 stdin to the command. The string is written as-is, line 12285 separators are not changed. 12286 If {input} is a |List| it is written to the pipe as 12287 |writefile()| does with {binary} set to "b" (i.e. with 12288 a newline between each list item, and newlines inside list 12289 items converted to NULs). 12290 When {input} is given and is a valid buffer id, the content of 12291 the buffer is written to the file line by line, each line 12292 terminated by NL (and NUL where the text has NL). 12293 *E5677* 12294 Note: system() cannot write to or read from backgrounded ("&") 12295 shell commands, e.g.: >vim 12296 echo system("cat - &", "foo") 12297 <which is equivalent to: > 12298 $ echo foo | bash -c 'cat - &' 12299 <The pipes are disconnected (unless overridden by shell 12300 redirection syntax) before input can reach it. Use 12301 |jobstart()| instead. 12302 12303 Note: Use |shellescape()| or |::S| with |expand()| or 12304 |fnamemodify()| to escape special characters in a command 12305 argument. 'shellquote' and 'shellxquote' must be properly 12306 configured. Example: >vim 12307 echo system('ls '..shellescape(expand('%:h'))) 12308 echo system('ls '..expand('%:h:S')) 12309 12310 <Unlike ":!cmd" there is no automatic check for changed files. 12311 Use |:checktime| to force a check. 12312 12313 ]=], 12314 name = 'system', 12315 params = { 12316 { 'cmd', 'string|string[]' }, 12317 { 'input', 'string|string[]|integer' }, 12318 }, 12319 returns = 'string', 12320 signature = 'system({cmd} [, {input}])', 12321 }, 12322 systemlist = { 12323 args = { 1, 3 }, 12324 base = 1, 12325 desc = [=[ 12326 Same as |system()|, but returns a |List| with lines (parts of 12327 output separated by NL) with NULs transformed into NLs. 12328 Output is the same as |readfile()| will output with {binary} 12329 argument set to "b", except that a final newline is not 12330 preserved, unless {keepempty} is non-zero. 12331 Note that on MS-Windows you may get trailing CR characters. 12332 12333 To see the difference between "echo hello" and "echo -n hello" 12334 use |system()| and |split()|: >vim 12335 echo split(system('echo hello'), '\n', 1) 12336 < 12337 Returns an empty string on error. 12338 12339 ]=], 12340 name = 'systemlist', 12341 params = { 12342 { 'cmd', 'string|string[]' }, 12343 { 'input', 'string|string[]|integer' }, 12344 { 'keepempty', 'integer' }, 12345 }, 12346 -- TODO(lewis6991): Not sure the '' return case is possible via vim.fn 12347 -- returns = "string[]|''", 12348 returns = 'string[]', 12349 signature = 'systemlist({cmd} [, {input} [, {keepempty}]])', 12350 }, 12351 tabpagebuflist = { 12352 args = { 0, 1 }, 12353 base = 1, 12354 desc = [=[ 12355 The result is a |List|, where each item is the number of the 12356 buffer associated with each window in the current tab page. 12357 {arg} specifies the number of the tab page to be used. When 12358 omitted the current tab page is used. 12359 When {arg} is invalid the number zero is returned. 12360 To get a list of all buffers in all tabs use this: >vim 12361 let buflist = [] 12362 for i in range(tabpagenr('$')) 12363 call extend(buflist, tabpagebuflist(i + 1)) 12364 endfor 12365 <Note that a buffer may appear in more than one window. 12366 12367 ]=], 12368 name = 'tabpagebuflist', 12369 params = { { 'arg', 'integer' } }, 12370 signature = 'tabpagebuflist([{arg}])', 12371 }, 12372 tabpagenr = { 12373 args = { 0, 1 }, 12374 desc = [=[ 12375 The result is a Number, which is the number of the current 12376 tab page. The first tab page has number 1. 12377 12378 The optional argument {arg} supports the following values: 12379 $ the number of the last tab page (the tab page 12380 count). 12381 # the number of the last accessed tab page 12382 (where |g<Tab>| goes to). If there is no 12383 previous tab page, 0 is returned. 12384 The number can be used with the |:tab| command. 12385 12386 Returns zero on error. 12387 ]=], 12388 name = 'tabpagenr', 12389 params = { { 'arg', "'$'|'#'" } }, 12390 returns = 'integer', 12391 signature = 'tabpagenr([{arg}])', 12392 }, 12393 tabpagewinnr = { 12394 args = { 1, 2 }, 12395 base = 1, 12396 desc = [=[ 12397 Like |winnr()| but for tab page {tabarg}. 12398 {tabarg} specifies the number of tab page to be used. 12399 {arg} is used like with |winnr()|: 12400 - When omitted the current window number is returned. This is 12401 the window which will be used when going to this tab page. 12402 - When "$" the number of windows is returned. 12403 - When "#" the previous window nr is returned. 12404 Useful examples: >vim 12405 tabpagewinnr(1) " current window of tab page 1 12406 tabpagewinnr(4, '$') " number of windows in tab page 4 12407 <When {tabarg} is invalid zero is returned. 12408 12409 ]=], 12410 name = 'tabpagewinnr', 12411 params = { { 'tabarg', 'integer' }, { 'arg', "'$'|'#'" } }, 12412 returns = 'integer', 12413 signature = 'tabpagewinnr({tabarg} [, {arg}])', 12414 }, 12415 tagfiles = { 12416 desc = [=[ 12417 Returns a |List| with the file names used to search for tags 12418 for the current buffer. This is the 'tags' option expanded. 12419 ]=], 12420 name = 'tagfiles', 12421 params = {}, 12422 returns = 'string[]', 12423 signature = 'tagfiles()', 12424 }, 12425 taglist = { 12426 args = { 1, 2 }, 12427 base = 1, 12428 desc = [=[ 12429 Returns a |List| of tags matching the regular expression {expr}. 12430 12431 If {filename} is passed it is used to prioritize the results 12432 in the same way that |:tselect| does. See |tag-priority|. 12433 {filename} should be the full path of the file. 12434 12435 Each list item is a dictionary with at least the following 12436 entries: 12437 name Name of the tag. 12438 filename Name of the file where the tag is 12439 defined. It is either relative to the 12440 current directory or a full path. 12441 cmd Ex command used to locate the tag in 12442 the file. 12443 kind Type of the tag. The value for this 12444 entry depends on the language specific 12445 kind values. Only available when 12446 using a tags file generated by 12447 Universal/Exuberant ctags or hdrtag. 12448 static A file specific tag. Refer to 12449 |static-tag| for more information. 12450 More entries may be present, depending on the content of the 12451 tags file: access, implementation, inherits and signature. 12452 Refer to the ctags documentation for information about these 12453 fields. For C code the fields "struct", "class" and "enum" 12454 may appear, they give the name of the entity the tag is 12455 contained in. 12456 12457 The ex-command "cmd" can be either an ex search pattern, a 12458 line number or a line number followed by a byte number. 12459 12460 If there are no matching tags, then an empty list is returned. 12461 12462 To get an exact tag match, the anchors '^' and '$' should be 12463 used in {expr}. This also make the function work faster. 12464 Refer to |tag-regexp| for more information about the tag 12465 search regular expression pattern. 12466 12467 Refer to 'tags' for information about how the tags file is 12468 located by Vim. Refer to |tags-file-format| for the format of 12469 the tags file generated by the different ctags tools. 12470 12471 ]=], 12472 name = 'taglist', 12473 params = { { 'expr', 'any' }, { 'filename', 'string' } }, 12474 signature = 'taglist({expr} [, {filename}])', 12475 }, 12476 tan = { 12477 args = 1, 12478 base = 1, 12479 desc = [=[ 12480 Return the tangent of {expr}, measured in radians, as a |Float| 12481 in the range [-inf, inf]. 12482 {expr} must evaluate to a |Float| or a |Number|. 12483 Returns 0.0 if {expr} is not a |Float| or a |Number|. 12484 Examples: >vim 12485 echo tan(10) 12486 < 0.648361 >vim 12487 echo tan(-4.01) 12488 < -1.181502 12489 12490 ]=], 12491 float_func = 'tan', 12492 name = 'tan', 12493 params = { { 'expr', 'number' } }, 12494 returns = 'number', 12495 signature = 'tan({expr})', 12496 }, 12497 tanh = { 12498 args = 1, 12499 base = 1, 12500 desc = [=[ 12501 Return the hyperbolic tangent of {expr} as a |Float| in the 12502 range [-1, 1]. 12503 {expr} must evaluate to a |Float| or a |Number|. 12504 Returns 0.0 if {expr} is not a |Float| or a |Number|. 12505 Examples: >vim 12506 echo tanh(0.5) 12507 < 0.462117 >vim 12508 echo tanh(-1) 12509 < -0.761594 12510 12511 ]=], 12512 float_func = 'tanh', 12513 name = 'tanh', 12514 params = { { 'expr', 'number' } }, 12515 returns = 'number', 12516 signature = 'tanh({expr})', 12517 }, 12518 tempname = { 12519 desc = [=[ 12520 Generates a (non-existent) filename located in the Nvim root 12521 |tempdir|. Scripts can use the filename as a temporary file. 12522 Example: >vim 12523 let tmpfile = tempname() 12524 exe "redir > " .. tmpfile 12525 < 12526 ]=], 12527 name = 'tempname', 12528 params = {}, 12529 returns = 'string', 12530 signature = 'tempname()', 12531 }, 12532 termopen = { 12533 deprecated = true, 12534 args = { 1, 2 }, 12535 desc = [=[ 12536 Use |jobstart()| with `{term: v:true}` instead. 12537 ]=], 12538 name = 'termopen', 12539 params = { { 'cmd', 'string|string[]' }, { 'opts', 'table' } }, 12540 returns = 'integer', 12541 signature = 'termopen({cmd} [, {opts}])', 12542 }, 12543 test_garbagecollect_now = { 12544 args = 0, 12545 desc = [=[ 12546 Like |garbagecollect()|, but executed right away. This must 12547 only be called directly to avoid any structure to exist 12548 internally, and |v:testing| must have been set before calling 12549 any function. *E1142* 12550 ]=], 12551 params = {}, 12552 signature = 'test_garbagecollect_now()', 12553 lua = false, 12554 }, 12555 test_write_list_log = { 12556 args = 1, 12557 params = { { 'fname', 'string' } }, 12558 lua = false, 12559 }, 12560 timer_info = { 12561 args = { 0, 1 }, 12562 base = 1, 12563 desc = [=[ 12564 Return a list with information about timers. 12565 When {id} is given only information about this timer is 12566 returned. When timer {id} does not exist an empty list is 12567 returned. 12568 When {id} is omitted information about all timers is returned. 12569 12570 For each timer the information is stored in a |Dictionary| with 12571 these items: 12572 "id" the timer ID 12573 "time" time the timer was started with 12574 "repeat" number of times the timer will still fire; 12575 -1 means forever 12576 "callback" the callback 12577 12578 ]=], 12579 name = 'timer_info', 12580 params = { { 'id', 'integer' } }, 12581 signature = 'timer_info([{id}])', 12582 }, 12583 timer_pause = { 12584 args = 2, 12585 base = 1, 12586 desc = [=[ 12587 Pause or unpause a timer. A paused timer does not invoke its 12588 callback when its time expires. Unpausing a timer may cause 12589 the callback to be invoked almost immediately if enough time 12590 has passed. 12591 12592 Pausing a timer is useful to avoid the callback to be called 12593 for a short time. 12594 12595 If {paused} evaluates to a non-zero Number or a non-empty 12596 String, then the timer is paused, otherwise it is unpaused. 12597 See |non-zero-arg|. 12598 12599 ]=], 12600 name = 'timer_pause', 12601 params = { { 'timer', 'integer' }, { 'paused', 'boolean' } }, 12602 signature = 'timer_pause({timer}, {paused})', 12603 }, 12604 timer_start = { 12605 args = { 2, 3 }, 12606 base = 1, 12607 tags = { 'timer' }, 12608 desc = [=[ 12609 Create a timer and return the timer ID. 12610 12611 {time} is the waiting time in milliseconds. This is the 12612 minimum time before invoking the callback. When the system is 12613 busy or Vim is not waiting for input the time will be longer. 12614 Zero can be used to execute the callback when Vim is back in 12615 the main loop. 12616 12617 {callback} is the function to call. It can be the name of a 12618 function or a |Funcref|. It is called with one argument, which 12619 is the timer ID. The callback is only invoked when Vim is 12620 waiting for input. 12621 12622 {options} is a dictionary. Supported entries: 12623 "repeat" Number of times to repeat the callback. 12624 -1 means forever. Default is 1. 12625 If the timer causes an error three times in a 12626 row the repeat is cancelled. 12627 12628 Returns -1 on error. 12629 12630 Example: >vim 12631 func MyHandler(timer) 12632 echo 'Handler called' 12633 endfunc 12634 let timer = timer_start(500, 'MyHandler', 12635 \ {'repeat': 3}) 12636 <This invokes MyHandler() three times at 500 msec intervals. 12637 12638 ]=], 12639 name = 'timer_start', 12640 params = { { 'time', 'number' }, { 'callback', 'string|function' }, { 'options', 'table' } }, 12641 signature = 'timer_start({time}, {callback} [, {options}])', 12642 }, 12643 timer_stop = { 12644 args = 1, 12645 base = 1, 12646 desc = [=[ 12647 Stop a timer. The timer callback will no longer be invoked. 12648 {timer} is an ID returned by |timer_start()|, thus it must be a 12649 Number. If {timer} does not exist there is no error. 12650 12651 ]=], 12652 name = 'timer_stop', 12653 params = { { 'timer', 'integer' } }, 12654 signature = 'timer_stop({timer})', 12655 }, 12656 timer_stopall = { 12657 args = 0, 12658 desc = [=[ 12659 Stop all timers. The timer callbacks will no longer be 12660 invoked. Useful if some timers is misbehaving. If there are 12661 no timers there is no error. 12662 ]=], 12663 name = 'timer_stopall', 12664 params = {}, 12665 signature = 'timer_stopall()', 12666 }, 12667 tolower = { 12668 args = 1, 12669 base = 1, 12670 desc = [=[ 12671 The result is a copy of the String given, with all uppercase 12672 characters turned into lowercase (just like applying |gu| to 12673 the string). Returns an empty string on error. 12674 12675 ]=], 12676 fast = true, 12677 name = 'tolower', 12678 params = { { 'expr', 'string' } }, 12679 returns = 'string', 12680 signature = 'tolower({expr})', 12681 }, 12682 toupper = { 12683 args = 1, 12684 base = 1, 12685 desc = [=[ 12686 The result is a copy of the String given, with all lowercase 12687 characters turned into uppercase (just like applying |gU| to 12688 the string). Returns an empty string on error. 12689 12690 ]=], 12691 fast = true, 12692 name = 'toupper', 12693 params = { { 'expr', 'string' } }, 12694 returns = 'string', 12695 signature = 'toupper({expr})', 12696 }, 12697 tr = { 12698 args = 3, 12699 base = 1, 12700 desc = [=[ 12701 The result is a copy of the {src} string with all characters 12702 which appear in {fromstr} replaced by the character in that 12703 position in the {tostr} string. Thus the first character in 12704 {fromstr} is translated into the first character in {tostr} 12705 and so on. Exactly like the unix "tr" command. 12706 This code also deals with multibyte characters properly. 12707 12708 Returns an empty string on error. 12709 12710 Examples: >vim 12711 echo tr("hello there", "ht", "HT") 12712 <returns "Hello THere" >vim 12713 echo tr("<blob>", "<>", "{}") 12714 <returns "{blob}" 12715 12716 ]=], 12717 name = 'tr', 12718 params = { { 'src', 'string' }, { 'fromstr', 'string' }, { 'tostr', 'string' } }, 12719 returns = 'string', 12720 signature = 'tr({src}, {fromstr}, {tostr})', 12721 }, 12722 trim = { 12723 args = { 1, 3 }, 12724 base = 1, 12725 desc = [=[ 12726 Return {text} as a String where any character in {mask} is 12727 removed from the beginning and/or end of {text}. 12728 12729 If {mask} is not given, or is an empty string, {mask} is all 12730 characters up to 0x20, which includes Tab, space, NL and CR, 12731 plus the non-breaking space character 0xa0. 12732 12733 The optional {dir} argument specifies where to remove the 12734 characters: 12735 0 remove from the beginning and end of {text} 12736 1 remove only at the beginning of {text} 12737 2 remove only at the end of {text} 12738 When omitted both ends are trimmed. 12739 12740 This function deals with multibyte characters properly. 12741 Returns an empty string on error. 12742 12743 Examples: >vim 12744 echo trim(" some text ") 12745 <returns "some text" >vim 12746 echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL" 12747 <returns "RESERVE_TAIL" >vim 12748 echo trim("rm<Xrm<>X>rrm", "rm<>") 12749 <returns "Xrm<>X" (characters in the middle are not removed) >vim 12750 echo trim(" vim ", " ", 2) 12751 <returns " vim" 12752 12753 ]=], 12754 name = 'trim', 12755 params = { { 'text', 'string' }, { 'mask', 'string' }, { 'dir', '0|1|2' } }, 12756 returns = 'string', 12757 signature = 'trim({text} [, {mask} [, {dir}]])', 12758 }, 12759 trunc = { 12760 args = 1, 12761 base = 1, 12762 desc = [=[ 12763 Return the largest integral value with magnitude less than or 12764 equal to {expr} as a |Float| (truncate towards zero). 12765 {expr} must evaluate to a |Float| or a |Number|. 12766 Returns 0.0 if {expr} is not a |Float| or a |Number|. 12767 Examples: >vim 12768 echo trunc(1.456) 12769 < 1.0 >vim 12770 echo trunc(-5.456) 12771 < -5.0 >vim 12772 echo trunc(4.0) 12773 < 4.0 12774 12775 ]=], 12776 float_func = 'trunc', 12777 name = 'trunc', 12778 params = { { 'expr', 'number' } }, 12779 returns = 'integer', 12780 signature = 'trunc({expr})', 12781 }, 12782 type = { 12783 args = 1, 12784 base = 1, 12785 desc = [=[ 12786 The result is a Number representing the type of {expr}. 12787 Instead of using the number directly, it is better to use the 12788 v:t_ variable that has the value: 12789 Number: 0 |v:t_number| 12790 String: 1 |v:t_string| 12791 Funcref: 2 |v:t_func| 12792 List: 3 |v:t_list| 12793 Dictionary: 4 |v:t_dict| 12794 Float: 5 |v:t_float| 12795 Boolean: 6 |v:t_bool| (|v:false| and |v:true|) 12796 Null: 7 (|v:null|) 12797 Blob: 10 |v:t_blob| 12798 For backward compatibility, this method can be used: >vim 12799 if type(myvar) == type(0) | endif 12800 if type(myvar) == type("") | endif 12801 if type(myvar) == type(function("tr")) | endif 12802 if type(myvar) == type([]) | endif 12803 if type(myvar) == type({}) | endif 12804 if type(myvar) == type(0.0) | endif 12805 if type(myvar) == type(v:true) | endif 12806 <In place of checking for |v:null| type it is better to check 12807 for |v:null| directly as it is the only value of this type: >vim 12808 if myvar is v:null | endif 12809 <To check if the v:t_ variables exist use this: >vim 12810 if exists('v:t_number') | endif 12811 < 12812 12813 ]=], 12814 fast = true, 12815 name = 'type', 12816 params = { { 'expr', 'any' } }, 12817 returns = 'integer', 12818 signature = 'type({expr})', 12819 }, 12820 undofile = { 12821 args = 1, 12822 base = 1, 12823 desc = [=[ 12824 Return the name of the undo file that would be used for a file 12825 with name {name} when writing. This uses the 'undodir' 12826 option, finding directories that exist. It does not check if 12827 the undo file exists. 12828 {name} is always expanded to the full path, since that is what 12829 is used internally. 12830 If {name} is empty undofile() returns an empty string, since a 12831 buffer without a file name will not write an undo file. 12832 Useful in combination with |:wundo| and |:rundo|. 12833 12834 ]=], 12835 name = 'undofile', 12836 params = { { 'name', 'string' } }, 12837 returns = 'string', 12838 signature = 'undofile({name})', 12839 }, 12840 undotree = { 12841 args = { 0, 1 }, 12842 base = 1, 12843 desc = [=[ 12844 Return the current state of the undo tree for the current 12845 buffer, or for a specific buffer if {buf} is given. The 12846 result is a dictionary with the following items: 12847 "seq_last" The highest undo sequence number used. 12848 "seq_cur" The sequence number of the current position in 12849 the undo tree. This differs from "seq_last" 12850 when some changes were undone. 12851 "time_cur" Time last used for |:earlier| and related 12852 commands. Use |strftime()| to convert to 12853 something readable. 12854 "save_last" Number of the last file write. Zero when no 12855 write yet. 12856 "save_cur" Number of the current position in the undo 12857 tree. 12858 "synced" Non-zero when the last undo block was synced. 12859 This happens when waiting from input from the 12860 user. See |undo-blocks|. 12861 "entries" A list of dictionaries with information about 12862 undo blocks. 12863 12864 The first item in the "entries" list is the oldest undo item. 12865 Each List item is a |Dictionary| with these items: 12866 "seq" Undo sequence number. Same as what appears in 12867 |:undolist|. 12868 "time" Timestamp when the change happened. Use 12869 |strftime()| to convert to something readable. 12870 "newhead" Only appears in the item that is the last one 12871 that was added. This marks the last change 12872 and where further changes will be added. 12873 "curhead" Only appears in the item that is the last one 12874 that was undone. This marks the current 12875 position in the undo tree, the block that will 12876 be used by a redo command. When nothing was 12877 undone after the last change this item will 12878 not appear anywhere. 12879 "save" Only appears on the last block before a file 12880 write. The number is the write count. The 12881 first write has number 1, the last one the 12882 "save_last" mentioned above. 12883 "alt" Alternate entry. This is again a List of undo 12884 blocks. Each item may again have an "alt" 12885 item. 12886 ]=], 12887 name = 'undotree', 12888 params = { { 'buf', 'integer|string' } }, 12889 returns = 'vim.fn.undotree.ret', 12890 signature = 'undotree([{buf}])', 12891 }, 12892 uniq = { 12893 args = { 1, 3 }, 12894 base = 1, 12895 tags = { 'E882' }, 12896 desc = [=[ 12897 Note: Prefer |vim.list.unique()| in Lua. 12898 12899 Remove second and succeeding copies of repeated adjacent 12900 {list} items in-place. Returns {list}. If you want a list 12901 to remain unmodified make a copy first: >vim 12902 let newlist = uniq(copy(mylist)) 12903 <The default compare function uses the string representation of 12904 each item. For the use of {func} and {dict} see |sort()|. 12905 For deduplicating text in the current buffer see |:uniq|. 12906 12907 Returns zero if {list} is not a |List|. 12908 12909 ]=], 12910 name = 'uniq', 12911 params = { { 'list', 'any' }, { 'func', 'any' }, { 'dict', 'any' } }, 12912 returns = 'any[]|0', 12913 signature = 'uniq({list} [, {func} [, {dict}]])', 12914 }, 12915 utf16idx = { 12916 args = { 2, 4 }, 12917 base = 1, 12918 desc = [=[ 12919 Same as |charidx()| but returns the UTF-16 code unit index of 12920 the byte at {idx} in {string} (after converting it to UTF-16). 12921 12922 When {charidx} is present and TRUE, {idx} is used as the 12923 character index in the String {string} instead of as the byte 12924 index. 12925 An {idx} in the middle of a UTF-8 sequence is rounded 12926 downwards to the beginning of that sequence. 12927 12928 Returns -1 if the arguments are invalid or if there are less 12929 than {idx} bytes in {string}. If there are exactly {idx} 12930 bytes, the length of the string in UTF-16 code units is 12931 returned. 12932 12933 See |byteidx()| and |byteidxcomp()| for getting the byte index 12934 from the UTF-16 index and |charidx()| for getting the 12935 character index from the UTF-16 index. 12936 Refer to |string-offset-encoding| for more information. 12937 Examples: >vim 12938 echo utf16idx('a😊😊', 3) " returns 2 12939 echo utf16idx('a😊😊', 7) " returns 4 12940 echo utf16idx('a😊😊', 1, 0, 1) " returns 2 12941 echo utf16idx('a😊😊', 2, 0, 1) " returns 4 12942 echo utf16idx('aą́c', 6) " returns 2 12943 echo utf16idx('aą́c', 6, 1) " returns 4 12944 echo utf16idx('a😊😊', 9) " returns -1 12945 < 12946 ]=], 12947 name = 'utf16idx', 12948 params = { 12949 { 'string', 'string' }, 12950 { 'idx', 'integer' }, 12951 { 'countcc', 'boolean' }, 12952 { 'charidx', 'boolean' }, 12953 }, 12954 returns = 'integer', 12955 signature = 'utf16idx({string}, {idx} [, {countcc} [, {charidx}]])', 12956 }, 12957 values = { 12958 args = 1, 12959 base = 1, 12960 desc = [=[ 12961 Return a |List| with all the values of {dict}. The |List| is 12962 in arbitrary order. Also see |items()| and |keys()|. 12963 Returns zero if {dict} is not a |Dict|. 12964 12965 ]=], 12966 name = 'values', 12967 params = { { 'dict', 'any' } }, 12968 signature = 'values({dict})', 12969 }, 12970 virtcol = { 12971 args = { 1, 3 }, 12972 base = 1, 12973 desc = [=[ 12974 The result is a Number, which is the screen column of the file 12975 position given with {expr}. That is, the total number of 12976 screen cells occupied by the part of the line until the end of 12977 the character at that position. When there is a <Tab> at the 12978 position, the returned Number will be the column at the end of 12979 the <Tab>. For example, for a <Tab> in column 1, with 'ts' 12980 set to 8, it returns 8. |conceal| is ignored. 12981 For the byte position use |col()|. 12982 12983 For the use of {expr} see |getpos()| and |col()|. 12984 When {expr} is "$", it means the end of the cursor line, so 12985 the result is the number of cells in the cursor line plus one. 12986 12987 When 'virtualedit' is used {expr} can be [lnum, col, off], 12988 where "off" is the offset in screen columns from the start of 12989 the character. E.g., a position within a <Tab> or after the 12990 last character. When "off" is omitted zero is used. When 12991 Virtual editing is active in the current mode, a position 12992 beyond the end of the line can be returned. Also see 12993 'virtualedit' 12994 12995 If {list} is present and non-zero then virtcol() returns a 12996 List with the first and last screen position occupied by the 12997 character. 12998 12999 With the optional {winid} argument the values are obtained for 13000 that window instead of the current window. 13001 13002 Note that only marks in the current file can be used. 13003 Examples: >vim 13004 " With text "foo^Lbar" and cursor on the "^L": 13005 13006 echo virtcol(".") " returns 5 13007 echo virtcol(".", 1) " returns [4, 5] 13008 echo virtcol("$") " returns 9 13009 13010 " With text " there", with 't at 'h': 13011 13012 echo virtcol("'t") " returns 6 13013 < 13014 The first column is 1. 0 or [0, 0] is returned for an error. 13015 13016 A more advanced example that echoes the maximum length of 13017 all lines: >vim 13018 echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) 13019 < 13020 13021 ]=], 13022 name = 'virtcol', 13023 params = { { 'expr', 'string|any[]' }, { 'list', 'boolean' }, { 'winid', 'integer' } }, 13024 returns = 'integer|[integer, integer]', 13025 signature = 'virtcol({expr} [, {list} [, {winid}]])', 13026 }, 13027 virtcol2col = { 13028 args = 3, 13029 base = 1, 13030 desc = [=[ 13031 The result is a Number, which is the byte index of the 13032 character in window {winid} at buffer line {lnum} and virtual 13033 column {col}. 13034 13035 If buffer line {lnum} is an empty line, 0 is returned. 13036 13037 If {col} is greater than the last virtual column in line 13038 {lnum}, then the byte index of the character at the last 13039 virtual column is returned. 13040 13041 For a multi-byte character, the column number of the first 13042 byte in the character is returned. 13043 13044 The {winid} argument can be the window number or the 13045 |window-ID|. If this is zero, then the current window is used. 13046 13047 Returns -1 if the window {winid} doesn't exist or the buffer 13048 line {lnum} or virtual column {col} is invalid. 13049 13050 See also |screenpos()|, |virtcol()| and |col()|. 13051 13052 ]=], 13053 name = 'virtcol2col', 13054 params = { { 'winid', 'integer' }, { 'lnum', 'integer' }, { 'col', 'integer' } }, 13055 returns = 'integer', 13056 signature = 'virtcol2col({winid}, {lnum}, {col})', 13057 }, 13058 visualmode = { 13059 args = { 0, 1 }, 13060 desc = [=[ 13061 The result is a String, which describes the last Visual mode 13062 used in the current buffer. Initially it returns an empty 13063 string, but once Visual mode has been used, it returns "v", 13064 "V", or "<CTRL-V>" (a single CTRL-V character) for 13065 character-wise, line-wise, or block-wise Visual mode 13066 respectively. 13067 Example: >vim 13068 exe "normal " .. visualmode() 13069 <This enters the same Visual mode as before. It is also useful 13070 in scripts if you wish to act differently depending on the 13071 Visual mode that was used. 13072 If Visual mode is active, use |mode()| to get the Visual mode 13073 (e.g., in a |:vmap|). 13074 If {expr} is supplied and it evaluates to a non-zero Number or 13075 a non-empty String, then the Visual mode will be cleared and 13076 the old value is returned. See |non-zero-arg|. 13077 ]=], 13078 name = 'visualmode', 13079 params = { { 'expr', 'boolean' } }, 13080 returns = 'string', 13081 signature = 'visualmode([{expr}])', 13082 }, 13083 wait = { 13084 args = { 2, 3 }, 13085 desc = [=[ 13086 Waits until {condition} evaluates to |TRUE|, where {condition} 13087 is a |Funcref| or |string| containing an expression. 13088 13089 {timeout} is the maximum waiting time in milliseconds, -1 13090 means forever. 13091 13092 Condition is evaluated on user events, internal events, and 13093 every {interval} milliseconds (default: 200). 13094 13095 Returns a status integer: 13096 0 if the condition was satisfied before timeout 13097 -1 if the timeout was exceeded 13098 -2 if the function was interrupted (by |CTRL-C|) 13099 -3 if an error occurred 13100 ]=], 13101 name = 'wait', 13102 params = { { 'timeout', 'integer' }, { 'condition', 'any' }, { 'interval', 'number' } }, 13103 signature = 'wait({timeout}, {condition} [, {interval}])', 13104 }, 13105 wildmenumode = { 13106 desc = [=[ 13107 Returns |TRUE| when the wildmenu is active and |FALSE| 13108 otherwise. See 'wildmenu' and 'wildmode'. 13109 This can be used in mappings to handle the 'wildcharm' option 13110 gracefully. (Makes only sense with |mapmode-c| mappings). 13111 13112 For example to make <c-j> work like <down> in wildmode, use: >vim 13113 cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>" 13114 < 13115 (Note: this needs the 'wildcharm' option set appropriately). 13116 ]=], 13117 name = 'wildmenumode', 13118 params = {}, 13119 signature = 'wildmenumode()', 13120 }, 13121 wildtrigger = { 13122 desc = [==[ 13123 Start wildcard expansion in the command-line, using the 13124 behavior defined by the 'wildmode' and 'wildoptions' settings. 13125 13126 This function also enables completion in search patterns such 13127 as |/|, |?|, |:s|, |:g|, |:v| and |:vimgrep|. 13128 13129 Unlike pressing 'wildchar' manually, this function does not 13130 produce a beep when no matches are found and generally 13131 operates more quietly. This makes it suitable for triggering 13132 completion automatically. 13133 13134 Note: After navigating command-line history, the first call to 13135 wildtrigger() is a no-op; a second call is needed to start 13136 expansion. This is to support history navigation in 13137 command-line autocompletion. 13138 13139 See |cmdline-autocompletion|. 13140 13141 Return value is always 0. 13142 ]==], 13143 name = 'wildtrigger', 13144 params = {}, 13145 returns = 'number', 13146 signature = 'wildtrigger()', 13147 }, 13148 win_execute = { 13149 args = { 2, 3 }, 13150 base = 2, 13151 desc = [=[ 13152 Like `execute()` but in the context of window {id}. 13153 The window will temporarily be made the current window, 13154 without triggering autocommands or changing directory. When 13155 executing {command} autocommands will be triggered, this may 13156 have unexpected side effects. Use `:noautocmd` if needed. 13157 Example: >vim 13158 call win_execute(winid, 'syntax enable') 13159 <Doing the same with `setwinvar()` would not trigger 13160 autocommands and not actually show syntax highlighting. 13161 13162 When window {id} does not exist then no error is given and 13163 an empty string is returned. 13164 13165 ]=], 13166 name = 'win_execute', 13167 params = { { 'id', 'integer' }, { 'command', 'string' }, { 'silent', 'boolean' } }, 13168 signature = 'win_execute({id}, {command} [, {silent}])', 13169 }, 13170 win_findbuf = { 13171 args = 1, 13172 base = 1, 13173 desc = [=[ 13174 Returns a |List| with |window-ID|s for windows that contain 13175 buffer {bufnr}. When there is none the list is empty. 13176 13177 ]=], 13178 name = 'win_findbuf', 13179 params = { { 'bufnr', 'integer' } }, 13180 returns = 'integer[]', 13181 signature = 'win_findbuf({bufnr})', 13182 }, 13183 win_getid = { 13184 args = { 0, 2 }, 13185 base = 1, 13186 desc = [=[ 13187 Get the |window-ID| for the specified window. 13188 When {win} is missing use the current window. 13189 With {win} this is the window number. The top window has 13190 number 1. 13191 Without {tab} use the current tab, otherwise the tab with 13192 number {tab}. The first tab has number one. 13193 Return zero if the window cannot be found. 13194 13195 ]=], 13196 name = 'win_getid', 13197 params = { { 'win', 'integer' }, { 'tab', 'integer' } }, 13198 returns = 'integer', 13199 signature = 'win_getid([{win} [, {tab}]])', 13200 }, 13201 win_gettype = { 13202 args = { 0, 1 }, 13203 base = 1, 13204 desc = [=[ 13205 Return the type of the window: 13206 "autocmd" autocommand window. Temporary window 13207 used to execute autocommands. 13208 "command" command-line window |cmdwin| 13209 (empty) normal window 13210 "loclist" |location-list-window| 13211 "popup" floating window |api-floatwin| 13212 "preview" preview window |preview-window| 13213 "quickfix" |quickfix-window| 13214 "unknown" window {nr} not found 13215 13216 When {nr} is omitted return the type of the current window. 13217 When {nr} is given return the type of this window by number or 13218 |window-ID|. 13219 13220 Also see the 'buftype' option. 13221 13222 ]=], 13223 name = 'win_gettype', 13224 params = { { 'nr', 'integer' } }, 13225 returns = "'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'", 13226 signature = 'win_gettype([{nr}])', 13227 }, 13228 win_gotoid = { 13229 args = 1, 13230 base = 1, 13231 desc = [=[ 13232 Go to window with ID {expr}. This may also change the current 13233 tabpage. 13234 Return TRUE if successful, FALSE if the window cannot be 13235 found. 13236 13237 ]=], 13238 name = 'win_gotoid', 13239 params = { { 'expr', 'integer' } }, 13240 returns = '0|1', 13241 signature = 'win_gotoid({expr})', 13242 }, 13243 win_id2tabwin = { 13244 args = 1, 13245 base = 1, 13246 desc = [=[ 13247 Return a list with the tab number and window number of window 13248 with ID {expr}: [tabnr, winnr]. 13249 Return [0, 0] if the window cannot be found. 13250 13251 ]=], 13252 name = 'win_id2tabwin', 13253 params = { { 'expr', 'integer' } }, 13254 signature = 'win_id2tabwin({expr})', 13255 }, 13256 win_id2win = { 13257 args = 1, 13258 base = 1, 13259 desc = [=[ 13260 Return the window number of window with ID {expr}. 13261 Return 0 if the window cannot be found in the current tabpage. 13262 13263 ]=], 13264 name = 'win_id2win', 13265 params = { { 'expr', 'integer' } }, 13266 returns = 'integer', 13267 signature = 'win_id2win({expr})', 13268 }, 13269 win_move_separator = { 13270 args = 2, 13271 base = 1, 13272 desc = [=[ 13273 Move window {nr}'s vertical separator (i.e., the right border) 13274 by {offset} columns, as if being dragged by the mouse. {nr} 13275 can be a window number or |window-ID|. A positive {offset} 13276 moves right and a negative {offset} moves left. Moving a 13277 window's vertical separator will change the width of the 13278 window and the width of other windows adjacent to the vertical 13279 separator. The magnitude of movement may be smaller than 13280 specified (e.g., as a consequence of maintaining 13281 'winminwidth'). Returns TRUE if the window can be found and 13282 FALSE otherwise. 13283 This will fail for the rightmost window and a full-width 13284 window, since it has no separator on the right. 13285 Only works for the current tab page. *E1308* 13286 13287 ]=], 13288 name = 'win_move_separator', 13289 params = { { 'nr', 'integer' }, { 'offset', 'integer' } }, 13290 signature = 'win_move_separator({nr}, {offset})', 13291 }, 13292 win_move_statusline = { 13293 args = 2, 13294 base = 1, 13295 desc = [=[ 13296 Move window {nr}'s status line (i.e., the bottom border) by 13297 {offset} rows, as if being dragged by the mouse. {nr} can be 13298 a window number or |window-ID|. A positive {offset} moves 13299 down and a negative {offset} moves up. Moving a window's 13300 status line will change the height of the window and the 13301 height of other windows adjacent to the status line. The 13302 magnitude of movement may be smaller than specified (e.g., as 13303 a consequence of maintaining 'winminheight'). Returns TRUE if 13304 the window can be found and FALSE otherwise. 13305 Only works for the current tab page. 13306 13307 ]=], 13308 name = 'win_move_statusline', 13309 params = { { 'nr', 'integer' }, { 'offset', 'integer' } }, 13310 signature = 'win_move_statusline({nr}, {offset})', 13311 }, 13312 win_screenpos = { 13313 args = 1, 13314 base = 1, 13315 desc = [=[ 13316 Return the screen position of window {nr} as a list with two 13317 numbers: [row, col]. The first window always has position 13318 [1, 1], unless there is a tabline, then it is [2, 1]. 13319 {nr} can be the window number or the |window-ID|. Use zero 13320 for the current window. 13321 Returns [0, 0] if the window cannot be found. 13322 ]=], 13323 name = 'win_screenpos', 13324 params = { { 'nr', 'integer' } }, 13325 signature = 'win_screenpos({nr})', 13326 }, 13327 win_splitmove = { 13328 args = { 2, 3 }, 13329 base = 1, 13330 desc = [=[ 13331 Temporarily switch to window {target}, then move window {nr} 13332 to a new split adjacent to {target}. 13333 Unlike commands such as |:split|, no new windows are created 13334 (the |window-ID| of window {nr} is unchanged after the move). 13335 13336 Both {nr} and {target} can be window numbers or |window-ID|s. 13337 Both must be in the current tab page. 13338 13339 Returns zero for success, non-zero for failure. 13340 13341 {options} is a |Dictionary| with the following optional entries: 13342 "vertical" When TRUE, the split is created vertically, 13343 like with |:vsplit|. 13344 "rightbelow" When TRUE, the split is made below or to the 13345 right (if vertical). When FALSE, it is done 13346 above or to the left (if vertical). When not 13347 present, the values of 'splitbelow' and 13348 'splitright' are used. 13349 13350 ]=], 13351 name = 'win_splitmove', 13352 params = { { 'nr', 'integer' }, { 'target', 'integer' }, { 'options', 'table' } }, 13353 signature = 'win_splitmove({nr}, {target} [, {options}])', 13354 }, 13355 winbufnr = { 13356 args = 1, 13357 base = 1, 13358 desc = [=[ 13359 The result is a Number, which is the number of the buffer 13360 associated with window {nr}. {nr} can be the window number or 13361 the |window-ID|. 13362 When {nr} is zero, the number of the buffer in the current 13363 window is returned. 13364 When window {nr} doesn't exist, -1 is returned. 13365 Example: >vim 13366 echo "The file in the current window is " .. bufname(winbufnr(0)) 13367 < 13368 ]=], 13369 name = 'winbufnr', 13370 params = { { 'nr', 'integer' } }, 13371 returns = 'integer', 13372 signature = 'winbufnr({nr})', 13373 }, 13374 wincol = { 13375 desc = [=[ 13376 The result is a Number, which is the virtual column of the 13377 cursor in the window. This is counting screen cells from the 13378 left side of the window. The leftmost column is one. 13379 ]=], 13380 name = 'wincol', 13381 params = {}, 13382 returns = 'integer', 13383 signature = 'wincol()', 13384 }, 13385 windowsversion = { 13386 desc = [=[ 13387 The result is a String. For MS-Windows it indicates the OS 13388 version. E.g, Windows 10 is "10.0", Windows 8 is "6.2", 13389 Windows XP is "5.1". For non-MS-Windows systems the result is 13390 an empty string. 13391 ]=], 13392 fast = true, 13393 name = 'windowsversion', 13394 params = {}, 13395 returns = 'string', 13396 signature = 'windowsversion()', 13397 }, 13398 winheight = { 13399 args = 1, 13400 base = 1, 13401 desc = [=[ 13402 Gets the height of |window-ID| {nr} (zero for "current 13403 window"), excluding any 'winbar' and 'statusline'. Returns -1 13404 if window {nr} doesn't exist. An existing window always has 13405 a height of zero or more. 13406 13407 Examples: >vim 13408 echo "Current window has " .. winheight(0) .. " lines." 13409 < 13410 ]=], 13411 name = 'winheight', 13412 params = { { 'nr', 'integer' } }, 13413 returns = 'integer', 13414 signature = 'winheight({nr})', 13415 }, 13416 winlayout = { 13417 args = { 0, 1 }, 13418 base = 1, 13419 desc = [=[ 13420 The result is a nested List containing the layout of windows 13421 in a tabpage. 13422 13423 Without {tabnr} use the current tabpage, otherwise the tabpage 13424 with number {tabnr}. If the tabpage {tabnr} is not found, 13425 returns an empty list. 13426 13427 For a leaf window, it returns: > 13428 ["leaf", {winid}] 13429 < 13430 For horizontally split windows, which form a column, it 13431 returns: > 13432 ["col", [{nested list of windows}]] 13433 <For vertically split windows, which form a row, it returns: > 13434 ["row", [{nested list of windows}]] 13435 < 13436 Example: >vim 13437 " Only one window in the tab page 13438 echo winlayout() 13439 < > 13440 ['leaf', 1000] 13441 < >vim 13442 " Two horizontally split windows 13443 echo winlayout() 13444 < > 13445 ['col', [['leaf', 1000], ['leaf', 1001]]] 13446 < >vim 13447 " The second tab page, with three horizontally split 13448 " windows, with two vertically split windows in the 13449 " middle window 13450 echo winlayout(2) 13451 < > 13452 ['col', [['leaf', 1002], ['row', [['leaf', 1003], 13453 ['leaf', 1001]]], ['leaf', 1000]]] 13454 < 13455 ]=], 13456 name = 'winlayout', 13457 params = { { 'tabnr', 'integer' } }, 13458 returns = 'vim.fn.winlayout.ret', 13459 signature = 'winlayout([{tabnr}])', 13460 }, 13461 winline = { 13462 desc = [=[ 13463 The result is a Number, which is the screen line of the cursor 13464 in the window. This is counting screen lines from the top of 13465 the window. The first line is one. 13466 If the cursor was moved the view on the file will be updated 13467 first, this may cause a scroll. 13468 ]=], 13469 name = 'winline', 13470 params = {}, 13471 returns = 'integer', 13472 signature = 'winline()', 13473 }, 13474 winnr = { 13475 args = { 0, 1 }, 13476 base = 1, 13477 desc = [=[ 13478 The result is a Number, which is the number of the current 13479 window. The top window has number 1. 13480 Returns zero for a hidden or non |focusable| window, unless 13481 it is the current window. 13482 13483 The optional argument {arg} supports the following values: 13484 $ the number of the last window (the window 13485 count). 13486 # the number of the last accessed window (where 13487 |CTRL-W_p| goes to). If there is no previous 13488 window or it is in another tab page 0 is 13489 returned. May refer to the current window in 13490 some cases (e.g. when evaluating 'statusline' 13491 expressions). 13492 {N}j the number of the Nth window below the 13493 current window (where |CTRL-W_j| goes to). 13494 {N}k the number of the Nth window above the current 13495 window (where |CTRL-W_k| goes to). 13496 {N}h the number of the Nth window left of the 13497 current window (where |CTRL-W_h| goes to). 13498 {N}l the number of the Nth window right of the 13499 current window (where |CTRL-W_l| goes to). 13500 The number can be used with |CTRL-W_w| and ":wincmd w" 13501 |:wincmd|. 13502 When {arg} is invalid an error is given and zero is returned. 13503 Also see |tabpagewinnr()| and |win_getid()|. 13504 Examples: >vim 13505 let window_count = winnr('$') 13506 let prev_window = winnr('#') 13507 let wnum = winnr('3k') 13508 < 13509 ]=], 13510 name = 'winnr', 13511 params = { { 'arg', 'string|integer' } }, 13512 returns = 'integer', 13513 signature = 'winnr([{arg}])', 13514 }, 13515 winrestcmd = { 13516 desc = [=[ 13517 Returns a sequence of |:resize| commands that should restore 13518 the current window sizes. Only works properly when no windows 13519 are opened or closed and the current window and tab page is 13520 unchanged. 13521 Example: >vim 13522 let cmd = winrestcmd() 13523 call MessWithWindowSizes() 13524 exe cmd 13525 < 13526 ]=], 13527 name = 'winrestcmd', 13528 params = {}, 13529 returns = 'string', 13530 signature = 'winrestcmd()', 13531 }, 13532 winrestview = { 13533 args = 1, 13534 base = 1, 13535 desc = [=[ 13536 Uses the |Dictionary| returned by |winsaveview()| to restore 13537 the view of the current window. 13538 Note: The {dict} does not have to contain all values, that are 13539 returned by |winsaveview()|. If values are missing, those 13540 settings won't be restored. So you can use: >vim 13541 call winrestview({'curswant': 4}) 13542 < 13543 This will only set the curswant value (the column the cursor 13544 wants to move on vertical movements) of the cursor to column 5 13545 (yes, that is 5), while all other settings will remain the 13546 same. This is useful, if you set the cursor position 13547 manually. 13548 13549 If you have changed the values the result is unpredictable. 13550 If the window size changed the result won't be the same. 13551 13552 ]=], 13553 name = 'winrestview', 13554 params = { { 'dict', 'vim.fn.winrestview.dict' } }, 13555 signature = 'winrestview({dict})', 13556 }, 13557 winsaveview = { 13558 desc = [=[ 13559 Returns a |Dictionary| that contains information to restore 13560 the view of the current window. Use |winrestview()| to 13561 restore the view. 13562 This is useful if you have a mapping that jumps around in the 13563 buffer and you want to go back to the original view. 13564 This does not save fold information. Use the 'foldenable' 13565 option to temporarily switch off folding, so that folds are 13566 not opened when moving around. This may have side effects. 13567 The return value includes: 13568 lnum cursor line number 13569 col cursor column (Note: the first column 13570 zero, as opposed to what |getcurpos()| 13571 returns) 13572 coladd cursor column offset for 'virtualedit' 13573 curswant column for vertical movement (Note: 13574 the first column is zero, as opposed 13575 to what |getcurpos()| returns). After 13576 |$| command it will be a very large 13577 number equal to |v:maxcol|. 13578 topline first line in the window 13579 topfill filler lines, only in diff mode 13580 leftcol first column displayed; only used when 13581 'wrap' is off 13582 skipcol columns skipped 13583 Note that no option values are saved. 13584 ]=], 13585 name = 'winsaveview', 13586 params = {}, 13587 signature = 'winsaveview()', 13588 returns = 'vim.fn.winsaveview.ret', 13589 }, 13590 winwidth = { 13591 args = 1, 13592 base = 1, 13593 desc = [=[ 13594 Gets the width of |window-ID| {nr} (zero for "current 13595 window"), including columns (|sign-column|, 'statuscolumn', 13596 etc.). Returns -1 if window {nr} doesn't exist. An existing 13597 window always has a width of zero or more. 13598 13599 Example: >vim 13600 echo "Current window has " .. winwidth(0) .. " columns." 13601 if winwidth(0) <= 50 13602 50 wincmd | 13603 endif 13604 < 13605 To get the buffer "viewport", use |getwininfo()|: >vim 13606 :echo getwininfo(win_getid())[0].width - getwininfo(win_getid())[0].textoff 13607 < 13608 To get the Nvim screen size, see the 'columns' option. 13609 ]=], 13610 name = 'winwidth', 13611 params = { { 'nr', 'integer' } }, 13612 returns = 'integer', 13613 signature = 'winwidth({nr})', 13614 }, 13615 wordcount = { 13616 desc = [=[ 13617 The result is a dictionary of byte/chars/word statistics for 13618 the current buffer. This is the same info as provided by 13619 |g_CTRL-G| 13620 The return value includes: 13621 bytes Number of bytes in the buffer 13622 chars Number of chars in the buffer 13623 words Number of words in the buffer 13624 cursor_bytes Number of bytes before cursor position 13625 (not in Visual mode) 13626 cursor_chars Number of chars before cursor position 13627 (not in Visual mode) 13628 cursor_words Number of words before cursor position 13629 (not in Visual mode) 13630 visual_bytes Number of bytes visually selected 13631 (only in Visual mode) 13632 visual_chars Number of chars visually selected 13633 (only in Visual mode) 13634 visual_words Number of words visually selected 13635 (only in Visual mode) 13636 ]=], 13637 name = 'wordcount', 13638 params = {}, 13639 signature = 'wordcount()', 13640 }, 13641 writefile = { 13642 args = { 2, 3 }, 13643 base = 1, 13644 desc = [=[ 13645 When {object} is a |List| write it to file {fname}. Each list 13646 item is separated with a NL. Each list item must be a String 13647 or Number. 13648 All NL characters are replaced with a NUL character. 13649 Inserting CR characters needs to be done before passing {list} 13650 to writefile(). 13651 13652 When {object} is a |Blob| write the bytes to file {fname} 13653 unmodified, also when binary mode is not specified. 13654 13655 {flags} must be a String. These characters are recognized: 13656 13657 'b' Binary mode is used: There will not be a NL after the 13658 last list item. An empty item at the end does cause the 13659 last line in the file to end in a NL. 13660 13661 'a' Append mode is used, lines are appended to the file: >vim 13662 call writefile(["foo"], "event.log", "a") 13663 call writefile(["bar"], "event.log", "a") 13664 < 13665 'D' Delete the file when the current function ends. This 13666 works like: >vim 13667 defer delete({fname}) 13668 < Fails when not in a function. Also see |:defer|. 13669 13670 's' fsync() is called after writing the file. This flushes 13671 the file to disk, if possible. This takes more time but 13672 avoids losing the file if the system crashes. 13673 13674 'S' fsync() is not called, even when 'fsync' is set. 13675 13676 When {flags} does not contain "S" or "s" then fsync() is 13677 called if the 'fsync' option is set. 13678 13679 An existing file is overwritten, if possible. 13680 13681 When the write fails -1 is returned, otherwise 0. There is an 13682 error message if the file can't be created or when writing 13683 fails. 13684 13685 Also see |readfile()|. 13686 To copy a file byte for byte: >vim 13687 let fl = readfile("foo", "b") 13688 call writefile(fl, "foocopy", "b") 13689 < 13690 13691 ]=], 13692 name = 'writefile', 13693 params = { { 'object', 'any' }, { 'fname', 'string' }, { 'flags', 'string' } }, 13694 signature = 'writefile({object}, {fname} [, {flags}])', 13695 }, 13696 xor = { 13697 args = 2, 13698 base = 1, 13699 desc = [=[ 13700 Bitwise XOR on the two arguments. The arguments are converted 13701 to a number. A List, Dict or Float argument causes an error. 13702 Also see `and()` and `or()`. 13703 Example: >vim 13704 let bits = xor(bits, 0x80) 13705 < 13706 ]=], 13707 name = 'xor', 13708 params = { { 'expr', 'integer' }, { 'expr', 'integer' } }, 13709 returns = 'integer', 13710 signature = 'xor({expr}, {expr})', 13711 }, 13712 } 13713 13714 return M