Mercurial > vim
diff runtime/doc/repeat.txt @ 11494:8e5ec22db3d8 v8.0.0630
patch 8.0.0630: it is not easy to work on lines without a match
commit https://github.com/vim/vim/commit/f84b122a99da75741ae686fabb6f81b8b4755998
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 10 14:29:52 2017 +0200
patch 8.0.0630: it is not easy to work on lines without a match
Problem: The :global command does not work recursively, which makes it
difficult to execute a command on a line where one pattern matches
and another does not match. (Miles Cranmer)
Solution: Allow for recursion if it is for only one line. (closes #1760)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 10 Jun 2017 14:30:03 +0200 |
parents | c391bfbdb452 |
children | a6d3e2081544 |
line wrap: on
line diff
--- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 8.0. Last change: 2017 Feb 06 +*repeat.txt* For Vim version 8.0. Last change: 2017 Jun 10 VIM REFERENCE MANUAL by Bram Moolenaar @@ -46,7 +46,7 @@ of area is used, see |visual-repeat|. ============================================================================== 2. Multiple repeats *multi-repeat* - *:g* *:global* *E147* *E148* + *:g* *:global* *E148* :[range]g[lobal]/{pattern}/[cmd] Execute the Ex command [cmd] (default ":p") on the lines within [range] where {pattern} matches. @@ -79,8 +79,15 @@ The default for [range] is the whole buf the command. If an error message is given for a line, the command for that line is aborted and the global command continues with the next marked or unmarked line. + *E147* +When the command is used recursively, it only works on one line. Giving a +range is then not allowed. This is useful to find all lines that match a +pattern and do not match another pattern: > + :g/found/v/notfound/{cmd} +This first finds all lines containing "found", but only executes {cmd} when +there is no match for "notfound". -To repeat a non-Ex command, you can use the ":normal" command: > +To execute a non-Ex command, you can use the `:normal` command: > :g/pat/normal {commands} Make sure that {commands} ends with a whole command, otherwise Vim will wait for you to type the rest of the command for each match. The screen will not