/[climacs]/climacs/Doc/climacs-user.texi
ViewVC logotype

Diff of /climacs/Doc/climacs-user.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by thenriksen, Sat Jul 1 23:11:19 2006 UTC revision 1.10 by thenriksen, Sun Jul 2 19:01:33 2006 UTC
# Line 556  this command will repeat the sequence of Line 556  this command will repeat the sequence of
556  @node Searching and replacing  @node Searching and replacing
557  @section Searching and replacing  @section Searching and replacing
558    
559    Climacs has a number of useful searching and replacing commands. The
560    replacing commands come in two flavors - querying commands and
561    non-querying commands. The former will unconditionally replace all
562    matches, while the latter will query before each replacement. Note that
563    the searching and replacing commands only affect the buffer contents
564    after point.
565    
566    @menu
567    * Simple search::
568    * Incremental search::
569    * The isearch command loop::
570    * Replacing single strings::
571    * Replacing multiple different strings::
572    * The query-replace command loop::
573    @end menu
574    
575    @node Simple search
576    @subsection Simple search
577    
578    The simplest search command is @command{String Search}. It prompts for a
579    string and moves point to after the next occurrence of the
580    string. @command{Reverse String Search} is similar, but searches
581    backwards from point, and puts point before the first occurrence of the
582    string.
583    
584    The commands @command{Word Search} and @command{Reverse Word Search} are
585    very similar to @command{String Search} and @command{Reverse String
586    Search}, but only finds matches that are whole words.
587    
588    The commands @command{Regex Search Forward} and @command{Regex Search
589    Backward} are similar to @command{String Search} and @command{Reverse
590    Word Search}, but do not search for plain strings. Instead, they ask the
591    user to enter a regular expression and attempts to find a match in the
592    buffer.
593    
594    You can use the command @command{How Many} to count the number of
595    matches in the buffer for a given regular expression. When invoked, the
596    command will ask for a regular expression, and then proceed to search
597    through the buffer, counting each match for the regular expression, and
598    finally print the number of matches to the minibuffer.
599    
600    @node Incremental search
601    @subsection Incremental search
602    
603    Incremental search, or @emph{isearch} in common speech, is different
604    from string search, in that point is moved to matches in the buffer,
605    while the search string is being entered, thus, the user receives
606    immediate feedback while entering the search string. Incremental search
607    is controlled through a command loop. @xref{The isearch command loop}.
608    
609    Incremental search can be entered via two orders, @kbd{C-s}
610    @kindex C-s
611    (@command{Isearch Forward}) and  @kbd{C-r}
612    @kindex C-r
613    (@command{Isearch Backward}). These commands starts a command loop that
614    searches forwards and backwards by default, respectively. Note that the
615    search direction can be changed from inside the command loop, no matter
616    which of these commands were used to start it.
617    
618    @node The isearch command loop
619    @subsection The isearch command loop
620    
621    The isearch command loop consists of the user typing in characters for
622    the search string, and Climacs moving point ahead to the most immediate
623    instance of the provided string, while the user is typing. Apart from
624    simply entering text, the user can manipulate the command loop by
625    entering the following orders:
626    
627    @table @kbd
628    @item C-s
629    Move to next match for current search string and set the search
630    direction to forward.
631    @item C-r
632    Move to previous match for current search string and set the search
633    direction to backward.
634    @item C-j
635    Append a ``newline'' character to the current search string.
636    @item C-w
637    Append the word at point to the current search string.
638    @item C-y
639    Append the line at point to the current search string.
640    @item M-y
641    Append the head of the kill ring to the search string.
642    @item @key{Backspace}
643    Delete the last element of the search string. This is not the same as
644    deleting the last character - for example, if the word at point has been
645    appended to the search string via @kbd{C-w}, this order will delete the
646    entire word, not just the last character of the word.
647    @item @key{Newline}
648    Exit the isearch command loop.
649    @end table
650    
651    @node Replacing single strings
652    @subsection Replacing single strings
653    
654    The basic string-replacement command can be accessed through the order
655    @kbd{C-x e}
656    @kindex C-x e
657    (@command{Replace String}). This command will prompt for two strings,
658    and replace all instances of the first string following point in the
659    current buffer, with the second string. This command is not querying,
660    and will thus not prompt before each replacement, so if you desire this
661    behavior, use the order @kbd{M-%}
662    @kindex M-%
663    (@command{Query Replace}) instead. @xref{The query-replace command loop}.
664    
665    @node Replacing multiple different strings
666    @subsection Replacing multiple different strings
667    
668    It is often desirable to be able to replace multiple, different strings
669    with one command - for instance, you might want to replace all
670    occurrences of ``foo'' with ``bar'' and all occurrences of ``bar'' with
671    ``baz'', without having the replacements affect each other. For this,
672    Climacs provides the command @command{Multiple Query Replace}, which
673    will prompt for pairs of strings, replacing the first with the second.
674    Entering an empty search string stops the prompting and starts the
675    query-replace command loop. It is also possible to use @command{Multiple
676    Query Replace From Buffer}, which will read the string pairs from a
677    buffer provided by the user.
678    
679    If you wish to exchange two strings for one another, use the command
680    @command{Query Exchange}, which will prompt for two strings, and replace
681    them for each other in the current buffer.
682    
683    @node The query-replace command loop
684    @subsection The query-replace command loop
685    
686    When invoking one of the querying replace commands, you will enter a
687    command loop with specialized commands for manipulating the replacement
688    process.
689    
690    The command loop will loop across the buffer, and for each match, the
691    command loop will read an order from the user. The following orders and
692    their corresponding commands are available:
693    
694    @table @kbd
695    @item y, @key{Space}
696    Replace the current match with the provided string, go to next
697    match.
698    @item n, @key{Rubout}, @key{Backspace}
699    Do not replace the current match, go to next match.
700    @item q, @key{Newline}
701    Quit the command loop, preserving all replacements already made.
702    @item .
703    Replace the current match with the provided string and quit the
704    command loop.
705    @item !
706    Replace all matches with the provided replacement strings.
707    @end table
708    
709  @node Getting help  @node Getting help
710  @chapter Getting help  @chapter Getting help
711    
# Line 568  prefix key.  The key following @kbd{C-h} Line 718  prefix key.  The key following @kbd{C-h}
718  information is displayed.  information is displayed.
719    
720  @menu  @menu
721    * Help with a command::
722  * Help with a key binding::  * Help with a key binding::
723  * Help with a particular key sequence::  * Help with a particular key sequence::
724    * Help finding a command::
725  * Help finding an order for a command::  * Help finding an order for a command::
726  @end menu  @end menu
727    
# Line 598  associated order (if any) is displayed i Line 750  associated order (if any) is displayed i
750  @section Help with a particular key sequence  @section Help with a particular key sequence
751    
752  To obtain a description of what some putative order will do, use the  To obtain a description of what some putative order will do, use the
753  order @kbd{C-h c}  order @kbd{C-h c}p
754  @kindex C-h c  @kindex C-h c
755  (@command{Describe Key Briefly}).  You will be prompted for a key  (@command{Describe Key Briefly}).  You will be prompted for a key
756  sequence.  If the key sequence you type is bound to a command, the  sequence.  If the key sequence you type is bound to a command, the

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.5