# Searching for and Replacing Text

## Executive Summary

### Searching

<Ctrl-F>            Begin search
<F3>                Find next
<Ctrl-R>            Begin search and replace

<Ctrl-Alt-U>        Clear match highlighting
<Alt-F>             Begin case-sensitive search
<Ctrl-Alt-F>        Begin upward search
<Shift-F3>          Find next upwards

While typing search expression:

<Enter>             Confirm search expression
<Esc> <Esc>         Abort search

### Grepping

<Alt-G>             Grep current buffer
<Alt-Shift-G>       Grep all buffers
<Ctrl-Alt-G>        Grep a directory

While typing grep expression:

<Up>, <Down>        Select a grep result to jump to
<Enter>             Jump to selected grep result
<F5>                Decrease context around matches
<F6>                Increase context around matches
<Esc> <Esc>         Abort grep


## Searching for Text

Press <Ctrl-F> to perform a case-insensitive search for text.  You will be
prompted for what to search for.  As you type your search expression,
matching text will be highlighted.  You can try it right now as you read this
document!  Press <Ctrl-F> and then type the word "text".  Press <Esc> twice to
abort the search.  If the find.return_on_abort setting is set to true, then the
cursor will return to where it was when the search began.  Otherwise, it will
remain where the last search brought it.

What you type will be interpreted as a regular expression.  (If you don't know
what a regular expression is, search the Internet, or read the Wikipedia
article: http://en.wikipedia.org/wiki/Regular_expression )

Press <Enter> to submit your search expression, and Diakonos will keep the
cursor on the first match it found and select it.  That is, it selects the
closest match below the point where you initiated the search.  Press <F3> to
move the cursor to the next match.

To clear the highlighting on matches, press <Ctrl-Alt-U>.

### Advanced Searching

Use <Alt-F> to do a case-sensitive regular expression search.  <Ctrl-Alt-F>
will search upwards (backwards), and <Shift-F3> will repeat a search upwards.

The findExact function will perform a search which does not consider the
search expression to be a regular expression, but rather a literal string.
There is no default key mapping for findExact; use <F12> to modify your
configuration.  Alternatively, you can press <Shift-F2> and enter "findExact"
to execute the function directly.

If you select text before searching, the search will be restricted to the
selected text.  Even repeated searches with <F3> will be restricted.

## Replacing Text

Press <Ctrl-R> to replace text.  As with searching, you will be prompted for
what to search for.  Press <Enter> to submit your search expression, and then
you will be prompted for the replacement text.  Press <Enter> to submit the
replacement text.

Diakonos will then highlight each individual match and ask whether or not you
wish to replace the selected text.  You can also choose to replace all matches
throughout the file at once.

The search expression you provide is considered a regular expression.  You can
also use parentheses to capture groups, and refer to those groups on your
replacement string with \1, \2, etc., which correspond to the first group, the
second group, etc.

## Grepping

Press <Ctrl-Alt-G> to begin grepping files under a directory (recursively).
Specify the directory, then press <Enter>. Then begin typing a regular
expression.  The display will update as you type according to the matches
found.  If you see a match you'd like to jump to, use <Down> (and <Up>) to
select a match, and press <Enter> to view that line of that file.  Press <Esc>
twice to abort the grep.

If you need to see more context around the matches, press <F6> during the grep.
<F5> reduces the context.  The grep.context setting is used for the default
amount of context to show.

Use <Alt-Shift-G> to grep through all open buffers, <Alt-G> to grep only the
current buffer.

Tags: search searching replace replacing find finding text string regex regexp regular expression grep grepping dir dirs directory buffer buffers file files
