mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
docs: more details about vim.region (#21116)
This commit is contained in:
@@ -1510,7 +1510,8 @@ print({...}) *vim.print()*
|
|||||||
|
|
||||||
region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive}) *vim.region()*
|
region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive}) *vim.region()*
|
||||||
Get a table of lines with start, end columns for a region marked by two
|
Get a table of lines with start, end columns for a region marked by two
|
||||||
points
|
points. Input and output positions are (0,0)-indexed and indicate byte
|
||||||
|
positions.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {bufnr} (integer) number of buffer
|
• {bufnr} (integer) number of buffer
|
||||||
@@ -1518,11 +1519,12 @@ region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive}) *vim.region()*
|
|||||||
region
|
region
|
||||||
• {pos2} integer[] (line, column) tuple marking end of region
|
• {pos2} integer[] (line, column) tuple marking end of region
|
||||||
• {regtype} (string) type of selection, see |setreg()|
|
• {regtype} (string) type of selection, see |setreg()|
|
||||||
• {inclusive} (boolean) indicating whether the selection is
|
• {inclusive} (boolean) indicating whether column of pos2 is inclusive
|
||||||
end-inclusive
|
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(table) region Table of the form `{linenr = {startcol,endcol}}`
|
(table) region Table of the form `{linenr = {startcol,endcol}}`.
|
||||||
|
`endcol` is exclusive, and whole lines are marked with
|
||||||
|
`{startcol,endcol} = {0,-1}`.
|
||||||
|
|
||||||
schedule_wrap({cb}) *vim.schedule_wrap()*
|
schedule_wrap({cb}) *vim.schedule_wrap()*
|
||||||
Defers callback `cb` until the Nvim API is safe to call.
|
Defers callback `cb` until the Nvim API is safe to call.
|
||||||
|
@@ -397,14 +397,17 @@ do
|
|||||||
vim.t = make_dict_accessor('t')
|
vim.t = make_dict_accessor('t')
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a table of lines with start, end columns for a region marked by two points
|
--- Get a table of lines with start, end columns for a region marked by two points.
|
||||||
|
--- Input and output positions are (0,0)-indexed and indicate byte positions.
|
||||||
---
|
---
|
||||||
---@param bufnr integer number of buffer
|
---@param bufnr integer number of buffer
|
||||||
---@param pos1 integer[] (line, column) tuple marking beginning of region
|
---@param pos1 integer[] (line, column) tuple marking beginning of region
|
||||||
---@param pos2 integer[] (line, column) tuple marking end of region
|
---@param pos2 integer[] (line, column) tuple marking end of region
|
||||||
---@param regtype string type of selection, see |setreg()|
|
---@param regtype string type of selection, see |setreg()|
|
||||||
---@param inclusive boolean indicating whether the selection is end-inclusive
|
---@param inclusive boolean indicating whether column of pos2 is inclusive
|
||||||
---@return table region Table of the form `{linenr = {startcol,endcol}}`
|
---@return table region Table of the form `{linenr = {startcol,endcol}}`.
|
||||||
|
--- `endcol` is exclusive, and whole lines are marked with
|
||||||
|
--- `{startcol,endcol} = {0,-1}`.
|
||||||
function vim.region(bufnr, pos1, pos2, regtype, inclusive)
|
function vim.region(bufnr, pos1, pos2, regtype, inclusive)
|
||||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||||
vim.fn.bufload(bufnr)
|
vim.fn.bufload(bufnr)
|
||||||
|
Reference in New Issue
Block a user