19 |
asks interactively which occurrences to replace. |
asks interactively which occurrences to replace. |
20 |
|
|
21 |
@menu |
@menu |
22 |
* Incremental Search:: Search happens as you type the string. |
* Incremental Search:: Search happens as you type the string. |
23 |
* Nonincremental Search:: Specify entire string and then search. |
* Nonincremental Search:: Specify entire string and then search. |
24 |
* Word Search:: Search for sequence of words. |
* Word Search:: Search for sequence of words. |
25 |
* Regexp Search:: Search for match for a regexp. |
* Regexp Search:: Search for match for a regexp. |
26 |
* Regexps:: Syntax of regular expressions. |
* Regexps:: Syntax of regular expressions. |
27 |
* Search Case:: To ignore case while searching, or not. |
* Search Case:: To ignore case while searching, or not. |
28 |
* Replace:: Search, and replace some or all matches. |
* Configuring Scrolling:: Scrolling within incremental search. |
29 |
* Other Repeating Search:: Operating on all matches for some regexp. |
* Replace:: Search, and replace some or all matches. |
30 |
|
* Other Repeating Search:: Operating on all matches for some regexp. |
31 |
@end menu |
@end menu |
32 |
|
|
33 |
@node Incremental Search, Nonincremental Search, Search, Search |
@node Incremental Search, Nonincremental Search, Search, Search |
227 |
of bindings, look at the documentation of @code{isearch-mode} with |
of bindings, look at the documentation of @code{isearch-mode} with |
228 |
@kbd{C-h f isearch-mode @key{RET}}. |
@kbd{C-h f isearch-mode @key{RET}}. |
229 |
|
|
230 |
|
@subsection Scrolling During Incremental Search |
231 |
|
|
232 |
|
Vertical scrolling during incremental search can be enabled by |
233 |
|
setting the customizable variable @code{isearch-allow-scroll} to a |
234 |
|
non-nil value. |
235 |
|
|
236 |
|
You can then use the vertical scroll-bar or certain keyboard |
237 |
|
commands such as @kbd{@key{PRIOR}} (@code{scroll-down}), |
238 |
|
@kbd{@key{NEXT}} (@code{scroll-up}) and @kbd{C-l} (@code{recenter}) |
239 |
|
within the search, thus letting you see more of the text near the |
240 |
|
current match. You must run these commands via their key sequences to |
241 |
|
stay in the search - typing M-x @var{comand-name} will always |
242 |
|
terminate a search. |
243 |
|
|
244 |
|
You can give prefix arguments to these commands in the usual way. |
245 |
|
The current match cannot be scrolled out of the window - this is |
246 |
|
intentional. |
247 |
|
|
248 |
|
Several other commands, such as @kbd{C-x 2} |
249 |
|
(@code{split-window-vertically}) and @kbd{C-x ^} |
250 |
|
(@code{enlarge-window}) which don't scroll the window, are |
251 |
|
nevertheless made available under this rubric, since they are likewise |
252 |
|
handy during a search. |
253 |
|
|
254 |
|
For a list of commands which are configured as scrolling commands by |
255 |
|
default and instructions on how thus to configure other commands, see |
256 |
|
@ref{Configuring Scrolling}. |
257 |
|
|
258 |
@subsection Slow Terminal Incremental Search |
@subsection Slow Terminal Incremental Search |
259 |
|
|
260 |
Incremental search on a slow terminal uses a modified style of display |
Incremental search on a slow terminal uses a modified style of display |
791 |
for matching parens.) |
for matching parens.) |
792 |
@end ignore |
@end ignore |
793 |
|
|
794 |
@node Search Case, Replace, Regexps, Search |
@node Search Case, Configuring Scrolling, Regexps, Search |
795 |
@section Searching and Case |
@section Searching and Case |
796 |
|
|
797 |
Incremental searches in Emacs normally ignore the case of the text |
Incremental searches in Emacs normally ignore the case of the text |
821 |
performed by the replace commands (@pxref{Replace}) and the minibuffer |
performed by the replace commands (@pxref{Replace}) and the minibuffer |
822 |
history matching commands (@pxref{Minibuffer History}). |
history matching commands (@pxref{Minibuffer History}). |
823 |
|
|
824 |
@node Replace, Other Repeating Search, Search Case, Search |
@node Configuring Scrolling, Replace, Search Case, Search |
825 |
|
@section Configuring Scrolling |
826 |
|
@cindex scrolling in incremental search |
827 |
|
@vindex isearch-allow-scroll |
828 |
|
|
829 |
|
Scrolling, etc., during incremental search is enabled by setting the |
830 |
|
customizable variable @code{isearch-allow-scroll} to a non-nil value. |
831 |
|
|
832 |
|
@c See Subject: Info file: How do I get an itemized list without blank lines? |
833 |
|
@c Date: Sat, 12 Apr 2003 09:45:31 +0000 in gnu.emacs.help |
834 |
|
@subsection Standard scrolling commands |
835 |
|
Here is the list of commands which are configured by default to be |
836 |
|
``scrolling'' commands in an incremental search, together with their |
837 |
|
usual bindings: |
838 |
|
@subsubsection Commands which scroll the window: |
839 |
|
@table @asis |
840 |
|
@item @code{scroll-bar-toolkit-scroll} (@kbd{@key{vertical-scroll-bar}@key{mouse-1}} in X-Windows) |
841 |
|
@itemx @code{mac-handle-scroll-bar-event} (@kbd{@key{vertical-scroll-bar}@key{mouse-1}} on a Mac) |
842 |
|
@itemx @code{w32-handle-scroll-bar-event} (@kbd{@key{vertical-scroll-bar}@key{mouse-1}} in MS-Windows) |
843 |
|
@item @code{recenter} (@kbd{C-l}) @xref{Scrolling}. |
844 |
|
@itemx @code{reposition-window} (@kbd{C-M-l}) @xref{Scrolling}. |
845 |
|
@itemx @code{scroll-up} (@kbd{@key{NEXT}}) @xref{Scrolling}. |
846 |
|
@itemx @code{scroll-down} (@kbd{@key{PRIOR}}) @xref{Scrolling}. |
847 |
|
@end table |
848 |
|
|
849 |
|
@subsubsection Commands which act on the other window: |
850 |
|
@table @asis |
851 |
|
@item @code{list-buffers} (@kbd{C-x C-b}) @xref{List Buffers}. |
852 |
|
@itemx @code{scroll-other-window} (@kbd{C-M-v}) @xref{Other Window}. |
853 |
|
@itemx @code{scroll-other-window-down} (@kbd{C-M-S-v}) @xref{Other Window}. |
854 |
|
@itemx @code{beginning-of-buffer-other-window} (@kbd{M-@key{home}}) |
855 |
|
@itemx @code{end-of-buffer-other-window} (@kbd{M-@key{end}}) |
856 |
|
@end table |
857 |
|
|
858 |
|
@subsubsection Commands which change the window layout: |
859 |
|
@table @asis |
860 |
|
@item @code{delete-other-windows} (@kbd{C-x 1}) @xref{Change Window}. |
861 |
|
@itemx @code{balance-windows} (@kbd{C-x +}) @xref{Change Window}. |
862 |
|
@itemx @code{split-window-vertically} (@kbd{C-x 2}) @xref{Split Window}. |
863 |
|
@itemx @code{enlarge-window} (@kbd{C-x ^}) @xref{Change Window}. |
864 |
|
@end table |
865 |
|
|
866 |
|
@subsection Configuring other commands as scrolling commands |
867 |
|
To do this, set a command's isearch-scroll property to the value t. |
868 |
|
For example: |
869 |
|
|
870 |
|
@example |
871 |
|
@code{(put 'my-command 'isearch-scroll t)} |
872 |
|
@end example |
873 |
|
|
874 |
|
You should only thus configure commands which are ``safe'': i.e., they |
875 |
|
won't leave emacs in an inconsistent state when executed within a |
876 |
|
search - that is to say, the following things may be changed by a |
877 |
|
command only temporarily, and must be restored before the command |
878 |
|
finishes: |
879 |
|
|
880 |
|
@enumerate |
881 |
|
@item |
882 |
|
Point. |
883 |
|
@item |
884 |
|
The buffer contents. |
885 |
|
@item |
886 |
|
The selected window and selected frame. |
887 |
|
@item |
888 |
|
The current match-data @xref{Match Data,,,elisp}. |
889 |
|
@end enumerate |
890 |
|
|
891 |
|
Additionally, the command must not delete the current window and must |
892 |
|
not itself attempt an incremental search. It may, however, change the |
893 |
|
window's size, or create or delete other windows and frames. |
894 |
|
|
895 |
|
Note that an attempt by a command to scroll the text |
896 |
|
@emph{horizontally} won't work, although it will do no harm - any such |
897 |
|
scrolling will be overriden and nullified by the display code. |
898 |
|
|
899 |
|
@node Replace, Other Repeating Search, Configuring Scrolling, Search |
900 |
@section Replacement Commands |
@section Replacement Commands |
901 |
@cindex replacement |
@cindex replacement |
902 |
@cindex search-and-replace commands |
@cindex search-and-replace commands |
918 |
(@pxref{Expanding Abbrevs}). |
(@pxref{Expanding Abbrevs}). |
919 |
|
|
920 |
@menu |
@menu |
921 |
* Unconditional Replace:: Replacing all matches for a string. |
* Unconditional Replace:: Replacing all matches for a string. |
922 |
* Regexp Replace:: Replacing all matches for a regexp. |
* Regexp Replace:: Replacing all matches for a regexp. |
923 |
* Replacement and Case:: How replacements preserve case of letters. |
* Replacement and Case:: How replacements preserve case of letters. |
924 |
* Query Replace:: How to use querying. |
* Query Replace:: How to use querying. |
925 |
@end menu |
@end menu |
926 |
|
|
927 |
@node Unconditional Replace, Regexp Replace, Replace, Replace |
@node Unconditional Replace, Regexp Replace, Replace, Replace |