Mercurial > vim
comparison runtime/doc/eval.txt @ 20725:f4455c71a8aa v8.2.0915
patch 8.2.0915: search() cannot skip over matches like searchpair() can
Commit: https://github.com/vim/vim/commit/adc17a5f9d207fd1623fd923457a46efc9214777
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 6 18:37:51 2020 +0200
patch 8.2.0915: search() cannot skip over matches like searchpair() can
Problem: Search() cannot skip over matches like searchpair() can.
Solution: Add an optional "skip" argument. (Christian Brabandt, closes https://github.com/vim/vim/issues/861)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 06 Jun 2020 18:45:03 +0200 |
parents | 770a8e9c4781 |
children | a672feb8fc4f |
comparison
equal
deleted
inserted
replaced
20724:b4f459787045 | 20725:f4455c71a8aa |
---|---|
2714 screenchars({row}, {col}) List List of characters at screen position | 2714 screenchars({row}, {col}) List List of characters at screen position |
2715 screencol() Number current cursor column | 2715 screencol() Number current cursor column |
2716 screenpos({winid}, {lnum}, {col}) Dict screen row and col of a text character | 2716 screenpos({winid}, {lnum}, {col}) Dict screen row and col of a text character |
2717 screenrow() Number current cursor row | 2717 screenrow() Number current cursor row |
2718 screenstring({row}, {col}) String characters at screen position | 2718 screenstring({row}, {col}) String characters at screen position |
2719 search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) | 2719 search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) |
2720 Number search for {pattern} | 2720 Number search for {pattern} |
2721 searchcount([{options}]) Dict get or update search stats | 2721 searchcount([{options}]) Dict get or update search stats |
2722 searchdecl({name} [, {global} [, {thisblock}]]) | 2722 searchdecl({name} [, {global} [, {thisblock}]]) |
2723 Number search for variable declaration | 2723 Number search for variable declaration |
2724 searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) | 2724 searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) |
2725 Number search for other end of start/end pair | 2725 Number search for other end of start/end pair |
2726 searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) | 2726 searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) |
2727 List search for other end of start/end pair | 2727 List search for other end of start/end pair |
2728 searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) | 2728 searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) |
2729 List search for {pattern} | 2729 List search for {pattern} |
2730 server2client({clientid}, {string}) | 2730 server2client({clientid}, {string}) |
2731 Number send reply string | 2731 Number send reply string |
2732 serverlist() String get a list of available servers | 2732 serverlist() String get a list of available servers |
2733 setbufline({expr}, {lnum}, {text}) | 2733 setbufline({expr}, {lnum}, {text}) |
8362 This is mainly to be used for testing. | 8362 This is mainly to be used for testing. |
8363 Returns an empty String when row or col is out of range. | 8363 Returns an empty String when row or col is out of range. |
8364 | 8364 |
8365 Can also be used as a |method|: > | 8365 Can also be used as a |method|: > |
8366 GetRow()->screenstring(col) | 8366 GetRow()->screenstring(col) |
8367 | 8367 < |
8368 search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()* | 8368 *search()* |
8369 search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) | |
8369 Search for regexp pattern {pattern}. The search starts at the | 8370 Search for regexp pattern {pattern}. The search starts at the |
8370 cursor position (you can use |cursor()| to set it). | 8371 cursor position (you can use |cursor()| to set it). |
8371 | 8372 |
8372 When a match has been found its line number is returned. | 8373 When a match has been found its line number is returned. |
8373 If there is no match a 0 is returned and the cursor doesn't | 8374 If there is no match a 0 is returned and the cursor doesn't |
8411 {timeout} is 500 the search stops after half a second. | 8412 {timeout} is 500 the search stops after half a second. |
8412 The value must not be negative. A zero value is like not | 8413 The value must not be negative. A zero value is like not |
8413 giving the argument. | 8414 giving the argument. |
8414 {only available when compiled with the |+reltime| feature} | 8415 {only available when compiled with the |+reltime| feature} |
8415 | 8416 |
8417 If the {skip} expression is given it is evaluated with the | |
8418 cursor positioned on the start of a match. If it evaluates to | |
8419 non-zero this match is skipped. This can be used, for | |
8420 example, to skip a match in a comment or a string. | |
8421 {skip} can be a string, which is evaluated as an expression, a | |
8422 function reference or a lambda. | |
8423 When {skip} is omitted or empty, every match is accepted. | |
8424 When evaluating {skip} causes an error the search is aborted | |
8425 and -1 returned. | |
8416 *search()-sub-match* | 8426 *search()-sub-match* |
8417 With the 'p' flag the returned value is one more than the | 8427 With the 'p' flag the returned value is one more than the |
8418 first sub-match in \(\). One if none of them matched but the | 8428 first sub-match in \(\). One if none of them matched but the |
8419 whole pattern did match. | 8429 whole pattern did match. |
8420 To get the column number too use |searchpos()|. | 8430 To get the column number too use |searchpos()|. |
8694 | 8704 |
8695 :let [lnum,col] = searchpairpos('{', '', '}', 'n') | 8705 :let [lnum,col] = searchpairpos('{', '', '}', 'n') |
8696 < | 8706 < |
8697 See |match-parens| for a bigger and more useful example. | 8707 See |match-parens| for a bigger and more useful example. |
8698 | 8708 |
8699 searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()* | 8709 *searchpos()* |
8710 searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) | |
8700 Same as |search()|, but returns a |List| with the line and | 8711 Same as |search()|, but returns a |List| with the line and |
8701 column position of the match. The first element of the |List| | 8712 column position of the match. The first element of the |List| |
8702 is the line number and the second element is the byte index of | 8713 is the line number and the second element is the byte index of |
8703 the column position of the match. If no match is found, | 8714 the column position of the match. If no match is found, |
8704 returns [0, 0]. | 8715 returns [0, 0]. |