Skip to content

Commit b4757e6

Browse files
Shougojustinmk
authored andcommitted
patch 9.1.0394: Cannot get a list of positions describing a region
Problem: Cannot get a list of positions describing a region (Justin M. Keyes, after v9.1.0120) Solution: Add the getregionpos() function (Shougo Matsushita) fixes: #14609 closes: #14617 Co-authored-by: Justin M. Keyes <[email protected]> Signed-off-by: Shougo Matsushita <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent c5def65 commit b4757e6

File tree

8 files changed

+353
-91
lines changed

8 files changed

+353
-91
lines changed

runtime/doc/builtin.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*builtin.txt* For Vim version 9.1. Last change: 2024 May 05
1+
*builtin.txt* For Vim version 9.1. Last change: 2024 May 07
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -265,6 +265,8 @@ getreg([{regname} [, 1 [, {list}]]])
265265
getreginfo([{regname}]) Dict information about a register
266266
getregion({pos1}, {pos2} [, {opts}])
267267
List get the text from {pos1} to {pos2}
268+
getregionpos({pos1}, {pos2} [, {opts}])
269+
List get a list of positions for a region
268270
getregtype([{regname}]) String type of a register
269271
getscriptinfo([{opts}]) List list of sourced scripts
270272
gettabinfo([{expr}]) List list of tab pages
@@ -4327,6 +4329,26 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()*
43274329
Can also be used as a |method|: >
43284330
getpos('.')->getregion(getpos("'a"))
43294331
<
4332+
getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
4333+
Same as |getregion()|, but returns a list of positions
4334+
describing the buffer text segments bound by {pos1} and
4335+
{pos2}.
4336+
The segments are a pair of positions for every line: >
4337+
[[{start_pos}, {end_pos}], ...]
4338+
<
4339+
The position is a |List| with four numbers:
4340+
[bufnum, lnum, col, off]
4341+
"bufnum" is the buffer number.
4342+
"lnum" and "col" are the position in the buffer. The first
4343+
column is 1.
4344+
The "off" number is zero, unless 'virtualedit' is used. Then
4345+
it is the offset in screen columns from the start of the
4346+
character. E.g., a position within a <Tab> or after the last
4347+
character.
4348+
4349+
Can also be used as a |method|: >
4350+
getpos('.')->getregionpos(getpos("'a"))
4351+
<
43304352
getregtype([{regname}]) *getregtype()*
43314353
The result is a String, which is type of register {regname}.
43324354
The value will be one of:

runtime/doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7799,6 +7799,7 @@ getreg() builtin.txt /*getreg()*
77997799
getreginfo() builtin.txt /*getreginfo()*
78007800
getregion() builtin.txt /*getregion()*
78017801
getregion-notes builtin.txt /*getregion-notes*
7802+
getregionpos() builtin.txt /*getregionpos()*
78027803
getregtype() builtin.txt /*getregtype()*
78037804
getscript pi_getscript.txt /*getscript*
78047805
getscript-autoinstall pi_getscript.txt /*getscript-autoinstall*

runtime/doc/usr_41.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_41.txt* For Vim version 9.1. Last change: 2024 Apr 26
1+
*usr_41.txt* For Vim version 9.1. Last change: 2024 May 07
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -930,6 +930,7 @@ Cursor and mark position: *cursor-functions* *mark-functions*
930930
Working with text in the current buffer: *text-functions*
931931
getline() get a line or list of lines from the buffer
932932
getregion() get a region of text from the buffer
933+
getregionpos() get a list of positions for a region
933934
setline() replace a line in the buffer
934935
append() append line or list of lines in the buffer
935936
indent() indent of a specific line

runtime/doc/version9.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41574,6 +41574,7 @@ Functions: ~
4157441574
|matchbufline()| all the matches of a pattern in a buffer
4157541575
|matchstrlist()| all the matches of a pattern in a List of strings
4157641576
|getregion()| get a region of text from a buffer
41577+
|getregionpos()| get a list of positions for a region
4157741578

4157841579

4157941580
Autocommands: ~

0 commit comments

Comments
 (0)