Mercurial > vim
comparison runtime/doc/builtin.txt @ 29193:1e9e9d89f0ee
Update runtime files
Commit: https://github.com/vim/vim/commit/d592deb336523a5448779ee3d4bba80334cff1f7
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 17 15:42:40 2022 +0100
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 17 Jun 2022 16:45:04 +0200 |
parents | 2a1f9b4a5ac9 |
children | f92f658585e6 |
comparison
equal
deleted
inserted
replaced
29192:e4488cf0eff9 | 29193:1e9e9d89f0ee |
---|---|
1 *builtin.txt* For Vim version 8.2. Last change: 2022 Jun 05 | 1 *builtin.txt* For Vim version 8.2. Last change: 2022 Jun 16 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
8807 exist it is omitted and counted as one character. For | 8807 exist it is omitted and counted as one character. For |
8808 example: > | 8808 example: > |
8809 strcharpart('abc', -1, 2) | 8809 strcharpart('abc', -1, 2) |
8810 < results in 'a'. | 8810 < results in 'a'. |
8811 | 8811 |
8812 Returns an empty string on error. | |
8813 | |
8812 Can also be used as a |method|: > | 8814 Can also be used as a |method|: > |
8813 GetText()->strcharpart(5) | 8815 GetText()->strcharpart(5) |
8814 | 8816 |
8815 | 8817 |
8816 strchars({string} [, {skipcc}]) *strchars()* | 8818 strchars({string} [, {skipcc}]) *strchars()* |
8818 in String {string}. | 8820 in String {string}. |
8819 When {skipcc} is omitted or zero, composing characters are | 8821 When {skipcc} is omitted or zero, composing characters are |
8820 counted separately. | 8822 counted separately. |
8821 When {skipcc} set to 1, Composing characters are ignored. | 8823 When {skipcc} set to 1, Composing characters are ignored. |
8822 |strcharlen()| always does this. | 8824 |strcharlen()| always does this. |
8825 | |
8826 Returns zero on error. | |
8823 | 8827 |
8824 Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. | 8828 Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. |
8825 | 8829 |
8826 {skipcc} is only available after 7.4.755. For backward | 8830 {skipcc} is only available after 7.4.755. For backward |
8827 compatibility, you can define a wrapper function: > | 8831 compatibility, you can define a wrapper function: > |
8851 The option settings of the current window are used. This | 8855 The option settings of the current window are used. This |
8852 matters for anything that's displayed differently, such as | 8856 matters for anything that's displayed differently, such as |
8853 'tabstop' and 'display'. | 8857 'tabstop' and 'display'. |
8854 When {string} contains characters with East Asian Width Class | 8858 When {string} contains characters with East Asian Width Class |
8855 Ambiguous, this function's return value depends on 'ambiwidth'. | 8859 Ambiguous, this function's return value depends on 'ambiwidth'. |
8860 Returns zero on error. | |
8856 Also see |strlen()|, |strwidth()| and |strchars()|. | 8861 Also see |strlen()|, |strwidth()| and |strchars()|. |
8857 | 8862 |
8858 Can also be used as a |method|: > | 8863 Can also be used as a |method|: > |
8859 GetText()->strdisplaywidth() | 8864 GetText()->strdisplaywidth() |
8860 | 8865 |
8884 Get a Number corresponding to the character at {index} in | 8889 Get a Number corresponding to the character at {index} in |
8885 {str}. This uses a zero-based character index, not a byte | 8890 {str}. This uses a zero-based character index, not a byte |
8886 index. Composing characters are considered separate | 8891 index. Composing characters are considered separate |
8887 characters here. Use |nr2char()| to convert the Number to a | 8892 characters here. Use |nr2char()| to convert the Number to a |
8888 String. | 8893 String. |
8894 Returns -1 if {index} is invalid. | |
8889 Also see |strcharpart()| and |strchars()|. | 8895 Also see |strcharpart()| and |strchars()|. |
8890 | 8896 |
8891 Can also be used as a |method|: > | 8897 Can also be used as a |method|: > |
8892 GetText()->strgetchar(5) | 8898 GetText()->strgetchar(5) |
8893 | 8899 |
8938 | 8944 |
8939 strlen({string}) *strlen()* | 8945 strlen({string}) *strlen()* |
8940 The result is a Number, which is the length of the String | 8946 The result is a Number, which is the length of the String |
8941 {string} in bytes. | 8947 {string} in bytes. |
8942 If the argument is a Number it is first converted to a String. | 8948 If the argument is a Number it is first converted to a String. |
8943 For other types an error is given. | 8949 For other types an error is given and zero is returned. |
8944 If you want to count the number of multibyte characters use | 8950 If you want to count the number of multibyte characters use |
8945 |strchars()|. | 8951 |strchars()|. |
8946 Also see |len()|, |strdisplaywidth()| and |strwidth()|. | 8952 Also see |len()|, |strdisplaywidth()| and |strwidth()|. |
8947 | 8953 |
8948 Can also be used as a |method|: > | 8954 Can also be used as a |method|: > |
8969 | 8975 |
8970 < Note: To get the first character, {start} must be 0. For | 8976 < Note: To get the first character, {start} must be 0. For |
8971 example, to get the character under the cursor: > | 8977 example, to get the character under the cursor: > |
8972 strpart(getline("."), col(".") - 1, 1, v:true) | 8978 strpart(getline("."), col(".") - 1, 1, v:true) |
8973 < | 8979 < |
8980 Returns an empty string on error. | |
8981 | |
8974 Can also be used as a |method|: > | 8982 Can also be used as a |method|: > |
8975 GetText()->strpart(5) | 8983 GetText()->strpart(5) |
8976 | 8984 |
8977 strptime({format}, {timestring}) *strptime()* | 8985 strptime({format}, {timestring}) *strptime()* |
8978 The result is a Number, which is a unix timestamp representing | 8986 The result is a Number, which is a unix timestamp representing |
9031 Like they are shown in a window. Example: > | 9039 Like they are shown in a window. Example: > |
9032 echo strtrans(@a) | 9040 echo strtrans(@a) |
9033 < This displays a newline in register a as "^@" instead of | 9041 < This displays a newline in register a as "^@" instead of |
9034 starting a new line. | 9042 starting a new line. |
9035 | 9043 |
9044 Returns an empty string on error. | |
9045 | |
9036 Can also be used as a |method|: > | 9046 Can also be used as a |method|: > |
9037 GetString()->strtrans() | 9047 GetString()->strtrans() |
9038 | 9048 |
9039 strwidth({string}) *strwidth()* | 9049 strwidth({string}) *strwidth()* |
9040 The result is a Number, which is the number of display cells | 9050 The result is a Number, which is the number of display cells |
9041 String {string} occupies. A Tab character is counted as one | 9051 String {string} occupies. A Tab character is counted as one |
9042 cell, alternatively use |strdisplaywidth()|. | 9052 cell, alternatively use |strdisplaywidth()|. |
9043 When {string} contains characters with East Asian Width Class | 9053 When {string} contains characters with East Asian Width Class |
9044 Ambiguous, this function's return value depends on 'ambiwidth'. | 9054 Ambiguous, this function's return value depends on 'ambiwidth'. |
9055 Returns zero on error. | |
9045 Also see |strlen()|, |strdisplaywidth()| and |strchars()|. | 9056 Also see |strlen()|, |strdisplaywidth()| and |strchars()|. |
9046 | 9057 |
9047 Can also be used as a |method|: > | 9058 Can also be used as a |method|: > |
9048 GetString()->strwidth() | 9059 GetString()->strwidth() |
9049 | 9060 |
9065 items, since there are no real line breaks. | 9076 items, since there are no real line breaks. |
9066 | 9077 |
9067 When substitute() is used recursively only the submatches in | 9078 When substitute() is used recursively only the submatches in |
9068 the current (deepest) call can be obtained. | 9079 the current (deepest) call can be obtained. |
9069 | 9080 |
9081 Returns an empty string or list on error. | |
9082 | |
9070 Examples: > | 9083 Examples: > |
9071 :s/\d\+/\=submatch(0) + 1/ | 9084 :s/\d\+/\=submatch(0) + 1/ |
9072 :echo substitute(text, '\d\+', '\=submatch(0) + 1', '') | 9085 :echo substitute(text, '\d\+', '\=submatch(0) + 1', '') |
9073 < This finds the first number in the line and adds one to it. | 9086 < This finds the first number in the line and adds one to it. |
9074 A line break is included as a newline character. | 9087 A line break is included as a newline character. |
9115 < The optional argument is a list which contains the whole | 9128 < The optional argument is a list which contains the whole |
9116 matched string and up to nine submatches, like what | 9129 matched string and up to nine submatches, like what |
9117 |submatch()| returns. Example: > | 9130 |submatch()| returns. Example: > |
9118 :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g') | 9131 :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g') |
9119 | 9132 |
9120 < Can also be used as a |method|: > | 9133 < Returns an empty string on error. |
9134 | |
9135 Can also be used as a |method|: > | |
9121 GetString()->substitute(pat, sub, flags) | 9136 GetString()->substitute(pat, sub, flags) |
9122 | 9137 |
9123 swapinfo({fname}) *swapinfo()* | 9138 swapinfo({fname}) *swapinfo()* |
9124 The result is a dictionary, which holds information about the | 9139 The result is a dictionary, which holds information about the |
9125 swapfile {fname}. The available fields are: | 9140 swapfile {fname}. The available fields are: |
9169 the effective color. When {trans} is |FALSE|, the transparent | 9184 the effective color. When {trans} is |FALSE|, the transparent |
9170 item is returned. This is useful when wanting to know which | 9185 item is returned. This is useful when wanting to know which |
9171 syntax item is effective (e.g. inside parens). | 9186 syntax item is effective (e.g. inside parens). |
9172 Warning: This function can be very slow. Best speed is | 9187 Warning: This function can be very slow. Best speed is |
9173 obtained by going through the file in forward direction. | 9188 obtained by going through the file in forward direction. |
9189 | |
9190 Returns zero on error. | |
9174 | 9191 |
9175 Example (echoes the name of the syntax item under the cursor): > | 9192 Example (echoes the name of the syntax item under the cursor): > |
9176 :echo synIDattr(synID(line("."), col("."), 1), "name") | 9193 :echo synIDattr(synID(line("."), col("."), 1), "name") |
9177 < | 9194 < |
9178 | 9195 |
9207 "standout" "1" if standout | 9224 "standout" "1" if standout |
9208 "underline" "1" if underlined | 9225 "underline" "1" if underlined |
9209 "undercurl" "1" if undercurled | 9226 "undercurl" "1" if undercurled |
9210 "strike" "1" if strikethrough | 9227 "strike" "1" if strikethrough |
9211 | 9228 |
9229 Returns an empty string on error. | |
9230 | |
9212 Example (echoes the color of the syntax item under the | 9231 Example (echoes the color of the syntax item under the |
9213 cursor): > | 9232 cursor): > |
9214 :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") | 9233 :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") |
9215 < | 9234 < |
9216 Can also be used as a |method|: > | 9235 Can also be used as a |method|: > |
9220 synIDtrans({synID}) *synIDtrans()* | 9239 synIDtrans({synID}) *synIDtrans()* |
9221 The result is a Number, which is the translated syntax ID of | 9240 The result is a Number, which is the translated syntax ID of |
9222 {synID}. This is the syntax group ID of what is being used to | 9241 {synID}. This is the syntax group ID of what is being used to |
9223 highlight the character. Highlight links given with | 9242 highlight the character. Highlight links given with |
9224 ":highlight link" are followed. | 9243 ":highlight link" are followed. |
9244 | |
9245 Returns zero on error. | |
9225 | 9246 |
9226 Can also be used as a |method|: > | 9247 Can also be used as a |method|: > |
9227 :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg") | 9248 :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg") |
9228 | 9249 |
9229 synconcealed({lnum}, {col}) *synconcealed()* | 9250 synconcealed({lnum}, {col}) *synconcealed()* |
9265 Example that shows the syntax stack under the cursor: > | 9286 Example that shows the syntax stack under the cursor: > |
9266 for id in synstack(line("."), col(".")) | 9287 for id in synstack(line("."), col(".")) |
9267 echo synIDattr(id, "name") | 9288 echo synIDattr(id, "name") |
9268 endfor | 9289 endfor |
9269 < When the position specified with {lnum} and {col} is invalid | 9290 < When the position specified with {lnum} and {col} is invalid |
9270 nothing is returned. The position just after the last | 9291 an empty List is returned. The position just after the last |
9271 character in a line and the first column in an empty line are | 9292 character in a line and the first column in an empty line are |
9272 valid positions. | 9293 valid positions. |
9273 | 9294 |
9274 system({expr} [, {input}]) *system()* *E677* | 9295 system({expr} [, {input}]) *system()* *E677* |
9275 Get the output of the shell command {expr} as a |String|. See | 9296 Get the output of the shell command {expr} as a |String|. See |
9378 count). | 9399 count). |
9379 # the number of the last accessed tab page | 9400 # the number of the last accessed tab page |
9380 (where |g<Tab>| goes to). if there is no | 9401 (where |g<Tab>| goes to). if there is no |
9381 previous tab page 0 is returned. | 9402 previous tab page 0 is returned. |
9382 The number can be used with the |:tab| command. | 9403 The number can be used with the |:tab| command. |
9404 | |
9405 Returns zero on error. | |
9383 | 9406 |
9384 | 9407 |
9385 tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()* | 9408 tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()* |
9386 Like |winnr()| but for tab page {tabarg}. | 9409 Like |winnr()| but for tab page {tabarg}. |
9387 {tabarg} specifies the number of tab page to be used. | 9410 {tabarg} specifies the number of tab page to be used. |
9451 | 9474 |
9452 tan({expr}) *tan()* | 9475 tan({expr}) *tan()* |
9453 Return the tangent of {expr}, measured in radians, as a |Float| | 9476 Return the tangent of {expr}, measured in radians, as a |Float| |
9454 in the range [-inf, inf]. | 9477 in the range [-inf, inf]. |
9455 {expr} must evaluate to a |Float| or a |Number|. | 9478 {expr} must evaluate to a |Float| or a |Number|. |
9479 Returns 0.0 if {expr} is not a |Float| or a |Number|. | |
9456 Examples: > | 9480 Examples: > |
9457 :echo tan(10) | 9481 :echo tan(10) |
9458 < 0.648361 > | 9482 < 0.648361 > |
9459 :echo tan(-4.01) | 9483 :echo tan(-4.01) |
9460 < -1.181502 | 9484 < -1.181502 |
9467 | 9491 |
9468 tanh({expr}) *tanh()* | 9492 tanh({expr}) *tanh()* |
9469 Return the hyperbolic tangent of {expr} as a |Float| in the | 9493 Return the hyperbolic tangent of {expr} as a |Float| in the |
9470 range [-1, 1]. | 9494 range [-1, 1]. |
9471 {expr} must evaluate to a |Float| or a |Number|. | 9495 {expr} must evaluate to a |Float| or a |Number|. |
9496 Returns 0.0 if {expr} is not a |Float| or a |Number|. | |
9472 Examples: > | 9497 Examples: > |
9473 :echo tanh(0.5) | 9498 :echo tanh(0.5) |
9474 < 0.462117 > | 9499 < 0.462117 > |
9475 :echo tanh(-1) | 9500 :echo tanh(-1) |
9476 < -0.761594 | 9501 < -0.761594 |
9596 If the timer causes an error three times in a | 9621 If the timer causes an error three times in a |
9597 row the repeat is cancelled. This avoids that | 9622 row the repeat is cancelled. This avoids that |
9598 Vim becomes unusable because of all the error | 9623 Vim becomes unusable because of all the error |
9599 messages. | 9624 messages. |
9600 | 9625 |
9626 Returns -1 on error. | |
9627 | |
9601 Example: > | 9628 Example: > |
9602 func MyHandler(timer) | 9629 func MyHandler(timer) |
9603 echo 'Handler called' | 9630 echo 'Handler called' |
9604 endfunc | 9631 endfunc |
9605 let timer = timer_start(500, 'MyHandler', | 9632 let timer = timer_start(500, 'MyHandler', |
9631 {only available when compiled with the |+timers| feature} | 9658 {only available when compiled with the |+timers| feature} |
9632 | 9659 |
9633 tolower({expr}) *tolower()* | 9660 tolower({expr}) *tolower()* |
9634 The result is a copy of the String given, with all uppercase | 9661 The result is a copy of the String given, with all uppercase |
9635 characters turned into lowercase (just like applying |gu| to | 9662 characters turned into lowercase (just like applying |gu| to |
9636 the string). | 9663 the string). Returns an empty string on error. |
9637 | 9664 |
9638 Can also be used as a |method|: > | 9665 Can also be used as a |method|: > |
9639 GetText()->tolower() | 9666 GetText()->tolower() |
9640 | 9667 |
9641 toupper({expr}) *toupper()* | 9668 toupper({expr}) *toupper()* |
9642 The result is a copy of the String given, with all lowercase | 9669 The result is a copy of the String given, with all lowercase |
9643 characters turned into uppercase (just like applying |gU| to | 9670 characters turned into uppercase (just like applying |gU| to |
9644 the string). | 9671 the string). Returns an empty string on error. |
9645 | 9672 |
9646 Can also be used as a |method|: > | 9673 Can also be used as a |method|: > |
9647 GetText()->toupper() | 9674 GetText()->toupper() |
9648 | 9675 |
9649 tr({src}, {fromstr}, {tostr}) *tr()* | 9676 tr({src}, {fromstr}, {tostr}) *tr()* |
9652 position in the {tostr} string. Thus the first character in | 9679 position in the {tostr} string. Thus the first character in |
9653 {fromstr} is translated into the first character in {tostr} | 9680 {fromstr} is translated into the first character in {tostr} |
9654 and so on. Exactly like the unix "tr" command. | 9681 and so on. Exactly like the unix "tr" command. |
9655 This code also deals with multibyte characters properly. | 9682 This code also deals with multibyte characters properly. |
9656 | 9683 |
9684 Returns an empty string on error. | |
9685 | |
9657 Examples: > | 9686 Examples: > |
9658 echo tr("hello there", "ht", "HT") | 9687 echo tr("hello there", "ht", "HT") |
9659 < returns "Hello THere" > | 9688 < returns "Hello THere" > |
9660 echo tr("<blob>", "<>", "{}") | 9689 echo tr("<blob>", "<>", "{}") |
9661 < returns "{blob}" | 9690 < returns "{blob}" |
9677 1 remove only at the beginning of {text} | 9706 1 remove only at the beginning of {text} |
9678 2 remove only at the end of {text} | 9707 2 remove only at the end of {text} |
9679 When omitted both ends are trimmed. | 9708 When omitted both ends are trimmed. |
9680 | 9709 |
9681 This function deals with multibyte characters properly. | 9710 This function deals with multibyte characters properly. |
9711 Returns an empty string on error. | |
9682 | 9712 |
9683 Examples: > | 9713 Examples: > |
9684 echo trim(" some text ") | 9714 echo trim(" some text ") |
9685 < returns "some text" > | 9715 < returns "some text" > |
9686 echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL" | 9716 echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL" |
9695 | 9725 |
9696 trunc({expr}) *trunc()* | 9726 trunc({expr}) *trunc()* |
9697 Return the largest integral value with magnitude less than or | 9727 Return the largest integral value with magnitude less than or |
9698 equal to {expr} as a |Float| (truncate towards zero). | 9728 equal to {expr} as a |Float| (truncate towards zero). |
9699 {expr} must evaluate to a |Float| or a |Number|. | 9729 {expr} must evaluate to a |Float| or a |Number|. |
9730 Returns 0.0 if {expr} is not a |Float| or a |Number|. | |
9700 Examples: > | 9731 Examples: > |
9701 echo trunc(1.456) | 9732 echo trunc(1.456) |
9702 < 1.0 > | 9733 < 1.0 > |
9703 echo trunc(-5.456) | 9734 echo trunc(-5.456) |
9704 < -5.0 > | 9735 < -5.0 > |
9813 to remain unmodified make a copy first: > | 9844 to remain unmodified make a copy first: > |
9814 :let newlist = uniq(copy(mylist)) | 9845 :let newlist = uniq(copy(mylist)) |
9815 < The default compare function uses the string representation of | 9846 < The default compare function uses the string representation of |
9816 each item. For the use of {func} and {dict} see |sort()|. | 9847 each item. For the use of {func} and {dict} see |sort()|. |
9817 | 9848 |
9849 Returns zero if {list} is not a |List|. | |
9850 | |
9818 Can also be used as a |method|: > | 9851 Can also be used as a |method|: > |
9819 mylist->uniq() | 9852 mylist->uniq() |
9820 | 9853 |
9821 values({dict}) *values()* | 9854 values({dict}) *values()* |
9822 Return a |List| with all the values of {dict}. The |List| is | 9855 Return a |List| with all the values of {dict}. The |List| is |
9823 in arbitrary order. Also see |items()| and |keys()|. | 9856 in arbitrary order. Also see |items()| and |keys()|. |
9857 Returns zero if {dict} is not a |Dict|. | |
9824 | 9858 |
9825 Can also be used as a |method|: > | 9859 Can also be used as a |method|: > |
9826 mydict->values() | 9860 mydict->values() |
9827 | 9861 |
9828 virtcol({expr} [, {list}]) *virtcol()* | 9862 virtcol({expr} [, {list}]) *virtcol()* |
9986 | 10020 |
9987 Also see the 'buftype' option. When running a terminal in a | 10021 Also see the 'buftype' option. When running a terminal in a |
9988 popup window then 'buftype' is "terminal" and win_gettype() | 10022 popup window then 'buftype' is "terminal" and win_gettype() |
9989 returns "popup". | 10023 returns "popup". |
9990 | 10024 |
10025 Return an empty string if the window cannot be found. | |
10026 | |
9991 Can also be used as a |method|: > | 10027 Can also be used as a |method|: > |
9992 GetWinid()->win_gettype() | 10028 GetWinid()->win_gettype() |
9993 < | 10029 < |
9994 win_gotoid({expr}) *win_gotoid()* | 10030 win_gotoid({expr}) *win_gotoid()* |
9995 Go to window with ID {expr}. This may also change the current | 10031 Go to window with ID {expr}. This may also change the current |
10023 window and the width of other windows adjacent to the vertical | 10059 window and the width of other windows adjacent to the vertical |
10024 separator. The magnitude of movement may be smaller than | 10060 separator. The magnitude of movement may be smaller than |
10025 specified (e.g., as a consequence of maintaining | 10061 specified (e.g., as a consequence of maintaining |
10026 'winminwidth'). Returns TRUE if the window can be found and | 10062 'winminwidth'). Returns TRUE if the window can be found and |
10027 FALSE otherwise. | 10063 FALSE otherwise. |
10064 This will fail for the rightmost window and a full-width | |
10065 window, since it has no separator on the right. | |
10028 | 10066 |
10029 Can also be used as a |method|: > | 10067 Can also be used as a |method|: > |
10030 GetWinnr()->win_move_separator(offset) | 10068 GetWinnr()->win_move_separator(offset) |
10031 | 10069 |
10032 win_move_statusline({nr}, {offset}) *win_move_statusline()* | 10070 win_move_statusline({nr}, {offset}) *win_move_statusline()* |