Artifact 345e0b3066b189e5be6920ae91eeb2819f984b19979dbb149a146421bebee726:
- File
psl-1983/3-1/doc/nmode/nm-replacement.r
— part of check-in
[eb17ceb7f6]
at
2020-04-21 19:40:01
on branch master
— Add Reduce 3.0 to the historical section of the archive, and some more
files relating to version sof PSL from the early 1980s. Thanks are due to
Paul McJones and Nelson Beebe for these, as well as to all the original
authors.git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/historical@5328 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 2962) [annotate] [blame] [check-ins using] [more...]
.so pndoc:nman .part NM-REPLACEMENT manual @Chapter[Replacement Commands] @node("replace") @index{searching} @index{replacement} @index{Replace String} Global search-and-replace operations are not needed as often in NMODE as they are in other editors, but they are available. In addition to the simple Replace operation which is like that found in most editors, there is a Query Replace operation which asks you, for each occurrence of the pattern, whether to replace it. @fncindex{replace-string-command} To replace every instance of FOO after point with BAR, you can do @example[ M-X Replace@return1{}FOO@return1{}BAR@return1{} ] This invokes @fnc{replace-string-command}. Replacement occurs only after point, so if you want to cover the whole buffer you must go to the beginning first. Replacement continues to the end of the buffer. @Section[Query Replace] @index{Query Replace} @fncindex{query-replace-command} If you want to change only some of the occurrences of FOO, not all, then you cannot use an ordinary Replace. Instead, use M-X Query Replace@return1{}FOO@return1{}BAR@return2{} (@fnc{query-replace-command}). This displays each occurrence of FOO and waits for you to say whether to replace it with a BAR. The things you can type when you are shown an occurrence of FOO are: @index{Space} @index{Rubout} @index{Comma} @keyindex{ESCape (Execute)} @index{.} @index{!} @index{^} @WideCommands{ Space to replace the FOO Rubout to skip to the next FOO without replacing this one. Comma to replace this FOO and display the result. You are then asked for another input character, except that since the replacement has already been made, Rubout and Space are equivalent. Escape to exit without doing any more replacements. Period to replace this FOO and then exit. ! to replace all remaining FOO's without asking. ^ to go back to the previous FOO (or, where it was), in case you have made a mistake. } If you type any other character, the Query Replace is exited, and the character executed as a command. @Section[Other Search-and-loop Functions] Here are some other functions related to replacement. Their arguments are strings. @fncindex{count-occurrences-command} @fncindex{delete-non-matching-lines-command} @fncindex{delete-matching-lines-command} @index{deletion}@index{replacement} @GrossCommands[ M-X How Many@return1{}FOO@return1{} invoke @fnc{count-occurrences-command} and print the number of occurrences of FOO after point. M-X Count Occurrences@return1{}FOO@return1{} Same as M-X How Many. M-X Keep Lines@return1{}FOO@return1{} invoke @fnc{delete-non-matching-lines-command} and kill all lines after point that don't contain FOO. M-X Delete Non-Matching Lines@return1{}FOO@return1{} Same as M-X Keep Lines. M-X Flush Lines@return1{}FOO@return1{} invoke @fnc{delete-matching-lines-command} and kill all lines after point that contain FOO. M-X Delete Matching Lines@return1{}FOO@return1{} Same as M-X Flush Lines. ]