geany/doc/html/ch03s06.html
Enrico Tröger 011fcde8ea Updated for Geany 0.11.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1551 ea778897-0a13-0410-b9d1-a72fbfd435f5
2007-05-21 15:24:27 +00:00

133 lines
13 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Search, replace and go to</title><link rel="stylesheet" href="geany.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="index.html" title="Geany 0.11"><link rel="up" href="ch03.html" title="Chapter 3. Usage"><link rel="prev" href="ch03s05.html" title="Editing"><link rel="next" href="ch03s07.html" title="Tags"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Search, replace and go to</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s05.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Usage</th><td width="20%" align="right"> <a accesskey="n" href="ch03s07.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="search"></a>Search, replace and go to</h2></div></div></div><p>
This section describes search-related commands from the Search menu and
the editor window's popup menu:
</p><p>
</p><div class="itemizedlist"><ul type="disc"><li><p>Find</p></li><li><p>Find usage *</p></li><li><p>Find in files</p></li><li><p>Replace</p></li><li><p>Go to tag definition *</p></li><li><p>Go to tag declaration *</p></li><li><p>Go to line</p></li></ul></div><p>
</p><p>
* These items are available from the editor window's popup menu, or by
using a keyboard shortcut (see <a href="ch03s12.html" title="Keybindings">the section called “Keybindings”</a>).
</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="search_find"></a>Find</h3></div></div></div><p>
The Find dialog is used for finding text in one or more open documents.
</p><p>
</p><div class="figure"><a name="id2810752"></a><p class="title"><b>Figure 3.1. Find dialog</b></p><div class="figure-contents"><div><img src="images/find_dialog.png" alt="Find dialog"></div></div></div><p><br class="figure-break">
</p><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="search_matchingoptions"></a>Matching options</h4></div></div></div><p>
The syntax for the <span class="emphasis"><em>Use regular expressions</em></span> option is shown in
<a href="ch03s06.html#regexp" title="Table 3.2. Regular expressions">Table 3.2, “Regular expressions”</a>.
</p><p>
The <span class="emphasis"><em>Use escape sequences</em></span> option will transform
any escaped characters into their UTF-8 equivalent. For example,
<code class="literal">\t</code> will be transformed into a tab character. Other
recognised symbols are:
<code class="literal">\\</code>, <code class="literal">\n</code>, <code class="literal">\r</code>,
<code class="literal">\uXXXX</code> (Unicode chararacters).
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2810833"></a>Find all</h4></div></div></div><p>
To find all matches, click on the <span class="emphasis"><em>Find All</em></span> expander.
This will reveal several options:
</p><div class="itemizedlist"><ul type="disc"><li><p>In Document</p></li><li><p>In Session</p></li><li><p>Mark</p></li></ul></div><p>
<span class="emphasis"><em>Find All In Document</em></span> will show a list of matching lines
in the current document in the Messages tab of the Message Window.
<span class="emphasis"><em>Find All In Session</em></span> does the same for all open documents.
</p><p>
<span class="emphasis"><em>Mark</em></span> will set markers for all matching lines in the
current document, if the Markers margin is visible.
If not, the background colour of matching lines will be highlighted.
Markers and highlighting can be removed by selecting the
<span class="emphasis"><em>Remove Markers</em></span> command from the
Document menu.
</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2810892"></a>Find usage</h3></div></div></div><p>
Find usage searches all open files. It is similar to the
<span class="emphasis"><em>Find All In Session</em></span> Find dialog command.
</p><p>
If there is a selection, then it is used
as the search text; otherwise the current word is used.
The current word is either taken from the word nearest the edit cursor, or
the word underneath the popup menu click position when the popup menu is
used.
The search results are shown in the Messages tab of the Message Window.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="search_fif"></a>Find in files</h3></div></div></div><p>
Find in files is a more powerful version of Find usage that searches all files
in a certain directory using the Grep tool. The Grep tool must be correctly set
in Preferences to the path of the system's Grep utility.
GNU Grep is recommended.
</p><p>
</p><div class="figure"><a name="id2810936"></a><p class="title"><b>Figure 3.2. Find in files dialog</b></p><div class="figure-contents"><div><img src="images/find_in_files_dialog.png" alt="Find in files dialog"></div></div></div><p><br class="figure-break">
</p><p>
The <span class="emphasis"><em>Extra options</em></span> field is used to pass any additional
arguments to the <code class="literal">grep</code> tool.
</p><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2810965"></a>Filtering out version control files</h4></div></div></div><p>
When using the <span class="emphasis"><em>Recurse in subfolders</em></span> option with a
directory that's under version control, you can set the
<span class="emphasis"><em>Extra options</em></span> field to use <code class="literal">grep</code>'s
<code class="literal">--exclude</code> flag to filter out filenames.
</p><p>
SVN Example: <code class="literal">--exclude=*.svn-base</code>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The GNU Grep project added support for excluding directories,
using the <code class="literal">--exclude-dir</code> flag.
At the time of writing (April 2007) this is unreleased outside
of version control.
Check your Grep manual to see if your version supports it.
</p><p>
Example: <code class="literal">--exclude-dir=.* --exclude-dir=CVS</code>
</p></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="search_replace"></a>Replace</h3></div></div></div><p>
The Replace dialog is used for replacing text in one or more open documents.
</p><p>
</p><div class="figure"><a name="id2811050"></a><p class="title"><b>Figure 3.3. Replace dialog</b></p><div class="figure-contents"><div><img src="images/replace_dialog.png" alt="Replace dialog"></div></div></div><p><br class="figure-break">
</p><p>
The Replace dialog has the same options for matching text as the Find
dialog. See <a href="ch03s06.html#search_matchingoptions" title="Matching options">the section called “Matching options”</a>.
</p><p>
The <span class="emphasis"><em>Use regular expressions</em></span> option applies both to the
search string and
to the replacement text; for the latter back references can be used -
see the entry for '\n' in <a href="ch03s06.html#regexp" title="Table 3.2. Regular expressions">Table 3.2, “Regular expressions”</a>.
</p><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2811092"></a>Replace all</h4></div></div></div><p>
To replace several matches, click on the <span class="emphasis"><em>Replace All</em></span>
expander. This will reveal several options:
</p><div class="itemizedlist"><ul type="disc"><li><p>In Document</p></li><li><p>In Session</p></li><li><p>In Selection</p></li></ul></div><p>
<span class="emphasis"><em>Replace All In Document</em></span> will replace all matching text
in the current document.
<span class="emphasis"><em>Replace All In Session</em></span> does the same for all open documents.
<span class="emphasis"><em>Replace All In Selection</em></span> will replace all matching text
in the current selection of the current document.
</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="search_gototag"></a>Go to tag definition</h3></div></div></div><p>
If the current word is the name of a tag definition (like a function body)
and the file containing the tag definition is open, this command will
switch to that file and go to the corresponding line number.
The current word is either taken from the word nearest the edit cursor, or
the word underneath the popup menu click position when the popup menu is
used.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2811169"></a>Go to tag declaration</h3></div></div></div><p>
Like Go to tag definition, but for a forward declaration such as a
function prototype or <code class="literal">extern</code> declaration instead
of a function body.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2811187"></a>Go to line</h3></div></div></div><p>
Go to a particular line number in the current file.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2811198"></a>Regular expressions</h3></div></div></div><p>
You can use regular expressions in the Find and Replace dialogs by
selecting the <span class="emphasis"><em>Use regular expressions</em></span> check box.
The syntax is POSIX-like, as described below in <a href="ch03s06.html#regexp" title="Table 3.2. Regular expressions">Table 3.2, “Regular expressions”</a>.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
Searching backwards with regular expressions is not supported.
</p></div><p>
</p><p>
</p><div class="table"><a name="regexp"></a><p class="title"><b>Table 3.2. Regular expressions</b></p><div class="table-contents"><table summary="Regular expressions" cellspacing="0" cellpadding="4" border="1"><colgroup><col><col></colgroup><thead><tr><th colspan="2" align="left">
In a regular expression, the following characters are interpreted:
</th></tr></thead><tbody><tr><td>.</td><td>Matches any character.</td></tr><tr><td>(</td><td>This marks the start of a region for tagging a match.</td></tr><tr><td>)</td><td>This marks the end of a tagged region.</td></tr><tr><td>\n</td><td>Where n is 1 through 9 refers to the first through ninth tagged region
when replacing. For example, if the search string was Fred([1-9])XXX
and the replace string was Sam\1YYY, when applied to Fred2XXX this would
generate Sam2YYY.
</td></tr><tr><td>\&lt;</td><td>This matches the start of a word.</td></tr><tr><td>\&gt;</td><td>This matches the end of a word.</td></tr><tr><td>\x</td><td>This allows you to use a character x that would otherwise have a special
meaning. For example, \[ would be interpreted as [ and not as the start
of a character set. Use \\ for a literal backslash.
</td></tr><tr><td>[...]</td><td>This indicates a set of characters, for example, [abc] means any of the
characters a, b or c. You can also use ranges, for example [a-z] for any
lower case character.
</td></tr><tr><td>[^...]</td><td>The complement of the characters in the set. For example, [^A-Za-z] means
any character except an alphabetic character.
</td></tr><tr><td>^</td><td>This matches the start of a line (unless used inside a set, see above).</td></tr><tr><td>$</td><td>This matches the end of a line.</td></tr><tr><td>*</td><td>This matches 0 or more times. For example, Sa*m matches Sm, Sam, Saam, Saaam and so on.</td></tr><tr><td>+</td><td>This matches 1 or more times. For example, Sa+m matches Sam, Saam, Saaam and so on.</td></tr></tbody></table></div></div><p><br class="table-break">
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Partial POSIX compatibility</h3><p>
Note that the POSIX '?' regular expression character for optional matching
is not supported by the Find and Replace dialogs.
</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Editing </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Tags</td></tr></table></div></body></html>