Mercurial > vim
comparison runtime/doc/eval.txt @ 5979:f9fa2e506b9f v7.4.330
updated for version 7.4.330
Problem: Using a regexp pattern to highlight a specific position can be
slow.
Solution: Add matchaddpos() to highlight specific positions efficiently.
(Alexey Radkov)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 17 Jun 2014 17:48:32 +0200 |
parents | 92751673cc37 |
children | ef83b423ebf7 |
comparison
equal
deleted
inserted
replaced
5978:4f8d7e5811e0 | 5979:f9fa2e506b9f |
---|---|
1885 String check for mappings matching {name} | 1885 String check for mappings matching {name} |
1886 match( {expr}, {pat}[, {start}[, {count}]]) | 1886 match( {expr}, {pat}[, {start}[, {count}]]) |
1887 Number position where {pat} matches in {expr} | 1887 Number position where {pat} matches in {expr} |
1888 matchadd( {group}, {pattern}[, {priority}[, {id}]]) | 1888 matchadd( {group}, {pattern}[, {priority}[, {id}]]) |
1889 Number highlight {pattern} with {group} | 1889 Number highlight {pattern} with {group} |
1890 matchaddpos( {group}, {list}[, {priority}[, {id}]]) | |
1891 Number highlight positions with {group} | |
1890 matcharg( {nr}) List arguments of |:match| | 1892 matcharg( {nr}) List arguments of |:match| |
1891 matchdelete( {id}) Number delete match identified by {id} | 1893 matchdelete( {id}) Number delete match identified by {id} |
1892 matchend( {expr}, {pat}[, {start}[, {count}]]) | 1894 matchend( {expr}, {pat}[, {start}[, {count}]]) |
1893 Number position where {pat} ends in {expr} | 1895 Number position where {pat} ends in {expr} |
1894 matchlist( {expr}, {pat}[, {start}[, {count}]]) | 1896 matchlist( {expr}, {pat}[, {start}[, {count}]]) |
4377 :call matchdelete(m) | 4379 :call matchdelete(m) |
4378 | 4380 |
4379 < A list of matches defined by |matchadd()| and |:match| are | 4381 < A list of matches defined by |matchadd()| and |:match| are |
4380 available from |getmatches()|. All matches can be deleted in | 4382 available from |getmatches()|. All matches can be deleted in |
4381 one operation by |clearmatches()|. | 4383 one operation by |clearmatches()|. |
4384 | |
4385 matchaddpos({group}, {pos}[, {priority}[, {id}]]) *matchaddpos()* | |
4386 Same as |matchadd()|, but requires a list of positions {pos} | |
4387 instead of a pattern. This command is faster than |matchadd()| | |
4388 because it does not require to handle regular expressions and | |
4389 sets buffer line boundaries to redraw screen. It is supposed | |
4390 to be used when fast match additions and deletions are | |
4391 required, for example to highlight matching parentheses. | |
4392 | |
4393 The list {pos} can contain one of these items: | |
4394 - A number. This while line will be highlighted. The first | |
4395 line has number 1. | |
4396 - A list with one number, e.g., [23]. The whole line with this | |
4397 number will be highlighted. | |
4398 - A list with two numbers, e.g., [23, 11]. The first number is | |
4399 the line number, the second one the column number (first | |
4400 column is 1). The character at this position will be | |
4401 highlighted. | |
4402 - A list with three numbers, e.g., [23, 11, 3]. As above, but | |
4403 the third number gives the length of the highlight in screen | |
4404 cells. | |
4405 | |
4406 The maximum number of positions is 8. | |
4407 | |
4408 Example: > | |
4409 :highlight MyGroup ctermbg=green guibg=green | |
4410 :let m = matchaddpos("MyGroup", [[23, 24], 34]) | |
4411 < Deletion of the pattern: > | |
4412 :call matchdelete(m) | |
4413 | |
4414 < Matches added by |matchaddpos()| are returned by | |
4415 |getmatches()| with an entry "pos1", "pos2", etc., with the | |
4416 value a list like the {pos} item. | |
4417 These matches cannot be set via |setmatches()|, however they | |
4418 can still be deleted by |clearmatches()|. | |
4382 | 4419 |
4383 matcharg({nr}) *matcharg()* | 4420 matcharg({nr}) *matcharg()* |
4384 Selects the {nr} match item, as set with a |:match|, | 4421 Selects the {nr} match item, as set with a |:match|, |
4385 |:2match| or |:3match| command. | 4422 |:2match| or |:3match| command. |
4386 Return a |List| with two elements: | 4423 Return a |List| with two elements: |