characters).
WARNING: When inserting or deleting text Vim does not automatically
update the matches. This means Syntax highlighting quickly becomes
wrong. Also when referring 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: >
/\%>43c.\%<46c
< Note that "\%<46c" matches in column 45 when the "." matches a byte in
column 44.
*/\%v* */\%>v* */\%<v*
\%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 six 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').
The "23" can be any column number. The first column is 1.
Note that some virtual column positions will never match, because they
are halfway through a tab or other character that occupies more than
one screen character.
WARNING: When inserting or deleting text Vim does not automatically
update highlighted matches. This means Syntax highlighting quickly
becomes wrong. Also when referring 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.
< This command does the same thing, but also matches when there is no
character in column 17: >
/^.*\%<18v.
< Note that without the "^" to anchor the match in the first column,
this will also highlight column 17: >
/.*\%17v
< Column 17 is highlighted by 'hlsearch' because there is another match
where ".*" matches zero characters.
Character classes:
\i identifier character (see 'isident' option) */\i*
\I like "\i", but excluding digits */\I*
\k keyword character (see 'iskeyword' option) */\k*
\K like "\k", but excluding digits */\K*
\f file name character (see 'isfname' option) */\f*
\F like "\f", but excluding digits */\F*
\p printable character (see 'isprint' option) */\p*
\P like "\p", but excluding digits */\P*
NOTE: the above also work for multibyte characters. The ones below only
match ASCII characters, as indicated by the range.
*whitespace* *white-space*
\s whitespace character: <Space> and <Tab> */\s*
\S non-whitespace character; opposite of \s */\S*
\d digit: [0-9] */\d*
\D non-digit: [^0-9] */\D*
\x hex digit: [0-9A-Fa-f] */\x*
\X non-hex digit: [^0-9A-Fa-f] */\X*
\o octal digit: [0-7] */\o*
\O non-octal digit: [^0-7] */\O*
\w word character: [0-9A-Za-z_] */\w*
\W non-word character: [^0-9A-Za-z_] */\W*
\h head of word character: [A-Za-z_] */\h*
\H non-head of word character: [^A-Za-z_] */\H*
\a alphabetic character: [A-Za-z] */\a*
\A non-alphabetic character: [^A-Za-z] */\A*
\l lowercase character: [a-z] */\l*
\L non-lowercase character: [^a-z] */\L*
\u uppercase character: [A-Z] */\u*
\U non-uppercase character: [^A-Z] */\U*
NOTE: Using the atom is faster than the [] form.
NOTE: