diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-03-22 15:14:51 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2023-03-22 17:46:01 +0100 |
commit | e51139f5c1d70bef1424f29e63eb527514e42865 (patch) | |
tree | 134cf61785edb963f67bb891da220dc3966cb3be /runtime/doc/lua.txt | |
parent | 8a70adbde03ee9931dc4e1b6f31bd8635eb3633b (diff) | |
download | rneovim-e51139f5c1d70bef1424f29e63eb527514e42865.tar.gz rneovim-e51139f5c1d70bef1424f29e63eb527514e42865.tar.bz2 rneovim-e51139f5c1d70bef1424f29e63eb527514e42865.zip |
refactor(vim.gsplit): remove "keepsep"
string.gmatch() is superior, use that instead.
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r-- | runtime/doc/lua.txt | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index a1fb7aa344..2baae3a123 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1659,12 +1659,18 @@ gsplit({s}, {sep}, {opts}) *vim.gsplit()* end < + If you want to also inspect the separator itself (instead of discarding + it), use |string.gmatch()|. Example: >lua + + for word, num in ('foo111bar222'):gmatch('([^0-9]*)(d*)') do + print(('word: s num: s'):format(word, num)) + end +< + Parameters: ~ - • {s} (string) String to split - • {sep} (string) Separator or pattern + • {s} string String to split + • {sep} string Separator or pattern • {opts} (table|nil) Keyword arguments |kwargs|: - • keepsep: (boolean) Return segments matching `sep` instead of - discarding them. • plain: (boolean) Use `sep` literally (as in string.find). • trimempty: (boolean) Discard empty segments at start and end of the sequence. @@ -1673,6 +1679,7 @@ gsplit({s}, {sep}, {opts}) *vim.gsplit()* (function) Iterator over the split components See also: ~ + • |string.gmatch()| • |vim.split()| • |luaref-patterns| • https://www.lua.org/pil/20.2.html @@ -1749,7 +1756,6 @@ split({s}, {sep}, {opts}) *vim.split()* split("axaby", "ab?") --> {'','x','y'} split("x*yz*o", "*", {plain=true}) --> {'x','yz','o'} split("|x|y|z|", "|", {trimempty=true}) --> {'x', 'y', 'z'} - split("|x|y|z|", "|", {keepsep=true}) --> {'|', 'x', '|', 'y', '|', 'z', '|'} < Parameters: ~ @@ -1763,6 +1769,7 @@ split({s}, {sep}, {opts}) *vim.split()* See also: ~ • |vim.gsplit()| + • |string.gmatch()| startswith({s}, {prefix}) *vim.startswith()* Tests if `s` starts with `prefix`. @@ -2625,7 +2632,7 @@ cmp({v1}, {v2}) *vim.version.cmp()* (integer) -1 if `v1 < v2`, 0 if `v1 == v2`, 1 if `v1 > v2`. eq({v1}, {v2}) *vim.version.eq()* - Returns `true` if the given versions are equal. + Returns `true` if the given versions are equal. See |vim.version.cmp()| for usage. Parameters: ~ • {v1} Version|number[] @@ -2635,7 +2642,7 @@ eq({v1}, {v2}) *vim.version.eq()* (boolean) gt({v1}, {v2}) *vim.version.gt()* - Returns `true` if `v1 > v2` . + Returns `true` if `v1 > v2` . See |vim.version.cmp()| for usage. Parameters: ~ • {v1} Version|number[] @@ -2654,7 +2661,7 @@ last({versions}) *vim.version.last()* Version ?|ni lt({v1}, {v2}) *vim.version.lt()* - Returns `true` if `v1 < v2` . + Returns `true` if `v1 < v2` . See |vim.version.cmp()| for usage. Parameters: ~ • {v1} Version|number[] |