diff options
Diffstat (limited to 'src/nvim/eval.lua')
-rw-r--r-- | src/nvim/eval.lua | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 8dc282cd43..7df4ab71ef 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3973,7 +3973,7 @@ M.funcs = { |getbufoneline()| ]=], name = 'getline', - params = { { 'lnum', 'integer' }, { 'end', 'nil|false' } }, + params = { { 'lnum', 'integer|string' }, { 'end', 'nil|false' } }, signature = 'getline({lnum} [, {end}])', returns = 'string', }, @@ -4359,43 +4359,49 @@ M.funcs = { args = { 2, 3 }, base = 1, desc = [=[ - Returns the list of strings from {pos1} to {pos2} in current + Returns the list of strings from {pos1} to {pos2} from a buffer. {pos1} and {pos2} must both be |List|s with four numbers. - See |getpos()| for the format of the list. + See |getpos()| for the format of the list. It's possible + to specify positions from a different buffer, but please + note the limitations at |getregion-notes|. The optional argument {opts} is a Dict and supports the following items: - type Specify the selection type + type Specify the region's selection type (default: "v"): "v" for |charwise| mode "V" for |linewise| mode "<CTRL-V>" for |blockwise-visual| mode exclusive If |TRUE|, use exclusive selection - for the end position 'selection'. + for the end position + (default: follow 'selection') You can get the last selection type by |visualmode()|. If Visual mode is active, use |mode()| to get the Visual mode (e.g., in a |:vmap|). - This function uses the line and column number from the - specified position. - It is useful to get text starting and ending in different - columns, such as |charwise-visual| selection. + This function is useful to get text starting and ending in + different columns, such as a |charwise-visual| selection. + *getregion-notes* Note that: - Order of {pos1} and {pos2} doesn't matter, it will always return content from the upper left position to the lower right position. - - If 'virtualedit' is enabled and selection is past the end of - line, resulting lines are filled with blanks. - - If the selection starts or ends in the middle of a multibyte - character, it is not included but its selected part is - substituted with spaces. - - If {pos1} or {pos2} is not current in the buffer, an empty + - If 'virtualedit' is enabled and the region is past the end + of the lines, resulting lines are padded with spaces. + - If the region is blockwise and it starts or ends in the + middle of a multi-cell character, it is not included but + its selected part is substituted with spaces. + - If {pos1} and {pos2} are not in the same buffer, an empty list is returned. + - {pos1} and {pos2} must belong to a |bufloaded()| buffer. + - It is evaluated in current window context, which makes a + difference if the buffer is displayed in a window with + different 'virtualedit' or 'list' values. Examples: > :xnoremap <CR> @@ -5220,7 +5226,7 @@ M.funcs = { ]=], name = 'indent', - params = { { 'lnum', 'integer' } }, + params = { { 'lnum', 'integer|string' } }, returns = 'integer', signature = 'indent({lnum})', }, @@ -7830,6 +7836,9 @@ M.funcs = { echo printf("%1$*2$.*3$f", 1.4142135, 6, 2) < 1.41 + You will get an overflow error |E1510|, when the field-width + or precision will result in a string longer than 6400 chars. + *E1500* You cannot mix positional and non-positional arguments: >vim echo printf("%s%1$s", "One", "Two") @@ -8740,6 +8749,7 @@ M.funcs = { When a match has been found its line number is returned. If there is no match a 0 is returned and the cursor doesn't move. No error message is given. + To get the matched string, use |matchbufline()|. {flags} is a String, which can contain these character flags: 'b' search Backward instead of forward @@ -12681,9 +12691,7 @@ M.funcs = { [1, 1], unless there is a tabline, then it is [2, 1]. {nr} can be the window number or the |window-ID|. Use zero for the current window. - Returns [0, 0] if the window cannot be found in the current - tabpage. - + Returns [0, 0] if the window cannot be found. ]=], name = 'win_screenpos', params = { { 'nr', 'integer' } }, @@ -12693,10 +12701,10 @@ M.funcs = { args = { 2, 3 }, base = 1, desc = [=[ - Move the window {nr} to a new split of the window {target}. - This is similar to moving to {target}, creating a new window - using |:split| but having the same contents as window {nr}, and - then closing {nr}. + Temporarily switch to window {target}, then move window {nr} + to a new split adjacent to {target}. + Unlike commands such as |:split|, no new windows are created + (the |window-ID| of window {nr} is unchanged after the move). Both {nr} and {target} can be window numbers or |window-ID|s. Both must be in the current tab page. @@ -12850,7 +12858,9 @@ M.funcs = { # the number of the last accessed window (where |CTRL-W_p| goes to). If there is no previous window or it is in another tab page 0 is - returned. + returned. May refer to the current window in + some cases (e.g. when evaluating 'statusline' + expressions). {N}j the number of the Nth window below the current window (where |CTRL-W_j| goes to). {N}k the number of the Nth window above the current |