diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-17 22:55:25 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-08-17 22:55:25 +0200 |
commit | 825cf813fa0fddf085fcbd3194781e875320ff63 (patch) | |
tree | 8c97b2ff072b1021d804514d5aa49e642e665bda /runtime | |
parent | b0efa49ed179d3aa1fa0358d4c3c6d35a0efb291 (diff) |
patch 9.0.1728: missing winid argument for virtcol()v9.0.1728
Problem: missing winid argument for virtcol()
Solution: Add a {winid} argument to virtcol()
Other functions col(), charcol() and virtcol2col() support a {winid}
argument, so it makes sense for virtcol() to also support than.
Also add test for virtcol2col() with 'showbreak' and {winid}.
closes: #12633
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/builtin.txt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 6a5ec1bacb..661876b24a 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -713,7 +713,8 @@ uniq({list} [, {func} [, {dict}]]) utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) Number UTF-16 index of byte {idx} in {string} values({dict}) List values in {dict} -virtcol({expr} [, {list}]) Number or List +virtcol({expr} [, {list} [, {winid}]) + Number or List screen column of cursor or mark virtcol2col({winid}, {lnum}, {col}) Number byte index of a character on screen @@ -10283,7 +10284,7 @@ values({dict}) *values()* Can also be used as a |method|: > mydict->values() -virtcol({expr} [, {list}]) *virtcol()* +virtcol({expr} [, {list} [, {winid}]]) *virtcol()* The result is a Number, which is the screen column of the file position given with {expr}. That is, the last screen position occupied by the character at that position, when the screen @@ -10315,10 +10316,13 @@ virtcol({expr} [, {list}]) *virtcol()* returns the cursor position. Differs from |'<| in that it's updated right away. - If {list} is present and non-zero then virtcol() returns a List - with the first and last screen position occupied by the + If {list} is present and non-zero then virtcol() returns a + List with the first and last screen position occupied by the character. + With the optional {winid} argument the values are obtained for + that window instead of the current window. + Note that only marks in the current file can be used. Examples: > " With text "foo^Lbar" and cursor on the "^L": @@ -10330,7 +10334,7 @@ virtcol({expr} [, {list}]) *virtcol()* " With text " there", with 't at 'h': virtcol("'t") " returns 6 -< The first column is 1. 0 is returned for an error. +< The first column is 1. 0 or [0, 0] is returned for an error. A more advanced example that echoes the maximum length of all lines: > echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) |