aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-19 16:42:24 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-03-30 08:35:13 +0800
commit1bbe8ec2820497b8a61adcd138da350445b0ad92 (patch)
treeb29ab8b57ff838acfeed0b4cbbad39dedde1d51c /runtime
parente5428d10b5a49e9395190482ff35bbac0c1117ea (diff)
downloadrneovim-1bbe8ec2820497b8a61adcd138da350445b0ad92.tar.gz
rneovim-1bbe8ec2820497b8a61adcd138da350445b0ad92.tar.bz2
rneovim-1bbe8ec2820497b8a61adcd138da350445b0ad92.zip
vim-patch:8.2.3110: a pattern that matches the cursor position is complicated
Problem: A pattern that matches the cursor position is bit complicated. Solution: Use a dot to indicate the cursor line and column. (Christian Brabandt, closes vim/vim#8497, closes vim/vim#8179) https://github.com/vim/vim/commit/04db26b36000a4677b95403ec94bd11f6cc73975 Also use `n = ++vcol` in regexp_bt.c as `++vcol` alone fails lint.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/pattern.txt31
1 files changed, 27 insertions, 4 deletions
diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index 680b853dab..c12a099469 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -918,13 +918,20 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
\%23l Matches in a specific line.
\%<23l Matches above a specific line (lower line number).
\%>23l Matches below a specific line (higher line number).
+\%.l Matches at the cursor line.
+\%<.l Matches above the cursor line.
+\%>.l Matches below the cursor line.
These three can be used to match specific lines in a buffer. The "23"
can be any line number. The first line is 1.
WARNING: When inserting or deleting lines Vim does not automatically
update the matches. This means Syntax highlighting quickly becomes
- wrong.
+ wrong. Also when refering to the cursor position (".") and
+ the cursor moves the display isn't updated for this change. An update
+ is done when using the |CTRL-L| command (the whole screen is updated).
Example, to highlight the line where the cursor currently is: >
- :exe '/\%' .. line(".") .. 'l.*'
+ :exe '/\%' .. line(".") .. 'l'
+< Alternatively use: >
+ /\%.l
< When 'hlsearch' is set and you move the cursor around and make changes
this will clearly show when the match is updated or not.
@@ -932,15 +939,23 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
\%23c Matches in a specific column.
\%<23c Matches before a specific column.
\%>23c Matches after a specific column.
+\%.c Matches at the cursor column.
+\%<.c Matches before the cursor column.
+\%>.c Matches after the cursor column.
These three can be used to match specific columns in a buffer or
string. The "23" can be any column number. The first column is 1.
Actually, the column is the byte number (thus it's not exactly right
for multibyte characters).
WARNING: When inserting or deleting text Vim does not automatically
update the matches. This means Syntax highlighting quickly becomes
- wrong.
+ wrong. Also when refering to the cursor position (".") and
+ the cursor moves the display isn't updated for this change. An update
+ is done when using the |CTRL-L| command (the whole screen is updated).
+
Example, to highlight the column where the cursor currently is: >
:exe '/\%' .. col(".") .. 'c'
+< Alternatively use: >
+ /\%.c
< When 'hlsearch' is set and you move the cursor around and make changes
this will clearly show when the match is updated or not.
Example for matching a single byte in column 44: >
@@ -951,6 +966,9 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
\%23v Matches in a specific virtual column.
\%<23v Matches before a specific virtual column.
\%>23v Matches after a specific virtual column.
+\%.v Matches at the current virtual column.
+\%<.v Matches before the current virtual column.
+\%>.v Matches after the current virtual column.
These three can be used to match specific virtual columns in a buffer
or string. When not matching with a buffer in a window, the option
values of the current window are used (e.g., 'tabstop').
@@ -960,13 +978,18 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
one screen character.
WARNING: When inserting or deleting text Vim does not automatically
update highlighted matches. This means Syntax highlighting quickly
- becomes wrong.
+ becomes wrong. Also when refering to the cursor position (".") and
+ the cursor moves the display isn't updated for this change. An update
+ is done when using the |CTRL-L| command (the whole screen is updated).
Example, to highlight all the characters after virtual column 72: >
/\%>72v.*
< When 'hlsearch' is set and you move the cursor around and make changes
this will clearly show when the match is updated or not.
To match the text up to column 17: >
/^.*\%17v
+< To match all characters after the current virtual column (where the
+ cursor is): >
+ /\%>.v.*
< Column 17 is not included, because this is a |/zero-width| match. To
include the column use: >
/^.*\%17v.