Mercurial > vim
diff runtime/doc/eval.txt @ 18017:988e5a868b60 v8.1.2004
patch 8.1.2004: more functions can be used as methods
Commit: https://github.com/vim/vim/commit/f6ed61e1489e40eada55a4f1782e1ed82bcad7d9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 7 19:05:09 2019 +0200
patch 8.1.2004: more functions can be used as methods
Problem: More functions can be used as methods.
Solution: Make various functions usable as a method.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 07 Sep 2019 19:15:04 +0200 |
parents | 8ae333756614 |
children | 8a2fb21c23c0 |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -8895,7 +8895,11 @@ sound_playevent({name} [, {callback}]) Returns the sound ID, which can be passed to `sound_stop()`. Returns zero if the sound could not be played. - {only available when compiled with the |+sound| feature} + + Can also be used as a |method|: > + GetSoundName()->sound_playevent() + +< {only available when compiled with the |+sound| feature} *sound_playfile()* sound_playfile({path} [, {callback}]) @@ -8903,6 +8907,10 @@ sound_playfile({path} [, {callback}]) must be a full path. On Ubuntu you may find files to play with this command: > :!find /usr/share/sounds -type f | grep -v index.theme + +< Can also be used as a |method|: > + GetSoundPath()->sound_playfile() + < {only available when compiled with the |+sound| feature} @@ -8913,7 +8921,10 @@ sound_stop({id}) *sound_stop()* On MS-Windows, this does not work for event sound started by `sound_playevent()`. To stop event sounds, use `sound_clear()`. - {only available when compiled with the |+sound| feature} + Can also be used as a |method|: > + soundid->sound_stop() + +< {only available when compiled with the |+sound| feature} *soundfold()* soundfold({word}) @@ -8924,6 +8935,9 @@ soundfold({word}) This can be used for making spelling suggestions. Note that the method can be quite slow. + Can also be used as a |method|: > + GetWord()->soundfold() +< *spellbadword()* spellbadword([{sentence}]) Without argument: The result is the badly spelled word under @@ -8950,6 +8964,9 @@ spellbadword([{sentence}]) 'spell' option must be set and the value of 'spelllang' is used. + Can also be used as a |method|: > + GetText()->spellbadword() +< *spellsuggest()* spellsuggest({word} [, {max} [, {capital}]]) Return a |List| with spelling suggestions to replace {word}. @@ -8973,6 +8990,8 @@ spellsuggest({word} [, {max} [, {capital 'spell' option must be set and the values of 'spelllang' and 'spellsuggest' are used. + Can also be used as a |method|: > + GetWord()->spellsuggest() split({expr} [, {pattern} [, {keepempty}]]) *split()* Make a |List| out of {expr}. When {pattern} is omitted or @@ -9069,6 +9088,19 @@ str2nr({expr} [, {base}]) *str2nr()* leading "0b" or "0B" is ignored. Text after the number is silently ignored. + Can also be used as a |method|: > + GetText()->str2nr() + +strcharpart({src}, {start} [, {len}]) *strcharpart()* + Like |strpart()| but using character index and length instead + of byte index and length. + When a character index is used where a character does not + exist it is assumed to be one character. For example: > + strcharpart('abc', -1, 2) +< results in 'a'. + + Can also be used as a |method|: > + GetText()->strcharpart(5) strchars({expr} [, {skipcc}]) *strchars()* The result is a Number, which is the number of characters @@ -9094,13 +9126,8 @@ strchars({expr} [, {skipcc}]) *strch endfunction endif < -strcharpart({src}, {start} [, {len}]) *strcharpart()* - Like |strpart()| but using character index and length instead - of byte index and length. - When a character index is used where a character does not - exist it is assumed to be one character. For example: > - strcharpart('abc', -1, 2) -< results in 'a'. + Can also be used as a |method|: > + GetText()->strchars() strdisplaywidth({expr} [, {col}]) *strdisplaywidth()* The result is a Number, which is the number of display cells @@ -9115,6 +9142,9 @@ strdisplaywidth({expr} [, {col}]) *str Ambiguous, this function's return value depends on 'ambiwidth'. Also see |strlen()|, |strwidth()| and |strchars()|. + Can also be used as a |method|: > + GetText()->strdisplaywidth() + strftime({format} [, {time}]) *strftime()* The result is a String, which is a formatted date and time, as specified by the {format} string. The given {time} is used, @@ -9134,12 +9164,18 @@ strftime({format} [, {time}]) *strfti < Not available on all systems. To check use: > :if exists("*strftime") +< Can also be used as a |method|: > + GetFormat()->strftime() + strgetchar({str}, {index}) *strgetchar()* Get character {index} from {str}. This uses a character index, not a byte index. Composing characters are considered separate characters here. Also see |strcharpart()| and |strchars()|. + Can also be used as a |method|: > + GetText()->strgetchar(5) + stridx({haystack}, {needle} [, {start}]) *stridx()* The result is a Number, which gives the byte index in {haystack} of the first occurrence of the String {needle}. @@ -9159,6 +9195,8 @@ stridx({haystack}, {needle} [, {start}]) stridx() works similar to the C function strstr(). When used with a single character it works similar to strchr(). + Can also be used as a |method|: > + GetHaystack()->stridx(needle) *string()* string({expr}) Return {expr} converted to a String. If {expr} is a Number, Float, String, Blob or a composition of them, then the result @@ -9211,6 +9249,9 @@ strpart({src}, {start} [, {len}]) *str example, to get three bytes under and after the cursor: > strpart(getline("."), col(".") - 1, 3) < + Can also be used as a |method|: > + GetText()->strpart(5) + strridx({haystack}, {needle} [, {start}]) *strridx()* The result is a Number, which gives the byte index in {haystack} of the last occurrence of the String {needle}. @@ -9229,6 +9270,9 @@ strridx({haystack}, {needle} [, {start}] When used with a single character it works similar to the C function strrchr(). + Can also be used as a |method|: > + GetHaystack()->strridx(needle) + strtrans({expr}) *strtrans()* The result is a String, which is {expr} with all unprintable characters translated into printable characters |'isprint'|. @@ -9277,6 +9321,9 @@ submatch({nr} [, {list}]) *submatch()* < This finds the first number in the line and adds one to it. A line break is included as a newline character. + Can also be used as a |method|: > + GetNr()->submatch() + substitute({expr}, {pat}, {sub}, {flags}) *substitute()* The result is a String, which is a copy of {expr}, in which the first match of {pat} is replaced with {sub}. @@ -9340,6 +9387,9 @@ swapinfo({fname}) *swapinfo()* Not a swap file: does not contain correct block ID Magic number mismatch: Info in first block is invalid + Can also be used as a |method|: > + GetFilename()->swapinfo() + swapname({expr}) *swapname()* The result is the swap file path of the buffer {expr}. For the use of {expr}, see |bufname()| above. @@ -9347,6 +9397,9 @@ swapname({expr}) *swapname()* |:swapname| (unless no swap file). If buffer {expr} has no swap file, returns an empty string. + Can also be used as a |method|: > + GetBufname()->swapname() + synID({lnum}, {col}, {trans}) *synID()* The result is a Number, which is the syntax ID at the position {lnum} and {col} in the current window.