C+f
) displays the search and replace
dialog box.
The search string can be entered in the Appendix C, History Text Fields for details.
text field. This text field remembers previously entered strings; seeIf text was selected in the text area and the selection does not span a line break, the selected text becomes the default search string.
If the selection spans a line break, the the section called “HyperSearch” for information about the HyperSearch feature.)
and buttons will be pre-selected, and the search string field will be initially blank. (SeeSelecting the Hello” will match “hello”, “HELLO” and “HeLlO”.
check box makes the search case insensitive - for example, searching for “To search for special characters (such as newlines or non-printable characters), inexact sequences of text, or strings that span multiple lines, we use Regular Expressions. Selecting the check box allows special characters to be used in the search string. Regular expression syntax is described in Appendix E, Regular Expressions.
The
and buttons specify the search direction. Note that regular expressions can only be used when searching in a forward direction.Clicking
will locate the next occurrence of the search string (or previous occurrence, if searching backwards). If the check box is selected, the dialog box will remain open after the search string has been located; otherwise, it will close.If no occurrences could be found and the
check box is selected, the search will automatically restart from the beginning of the buffer (or the end, if searching backwards). If is not selected, a confirmation dialog box is shown before restarting the search.C+g
) locates the next
occurrence of the most recent search string without displaying the
search and replace dialog box.
C+h
) locates the
previous occurrence of the most recent search string without
displaying the search and replace dialog box.
The replace string text field of the search dialog remembers previously entered strings; see Appendix C, History Text Fields for details.
Clicking
will perform a replacement in the current selection and locate the next occurrence of the search string. Clicking will replace all occurrences of the search string with the replacement string in the current search scope (which is either the selection, the current buffer, or a set of buffers, as specified in the search and replace dialog box).Occurrences of the search string can be replaced with either a replacement string, or the return value of a BeanShell script snippet. Two radio buttons in the search and replace dialog box select between the two replacement modes, which are described in detail below.
If the
button is selected, the search string is simply replaced with the replacement string.If regular expressions are enabled, positional parameters
($0
, $1
,
$2
, and so on) can be used to insert the
contents of matched subexpressions in the replacement string;
see Appendix E, Regular Expressions for more information.
If the search is case-insensitive, jEdit attempts to modify the case of the replacement string to match that of the particular instance of the search string being replaced. For example, searching for “label” and replacing it with “text”, will perform the following replacements:
“String label” would become “String text”
“setLabel” would become “setText”
“DEFAULT_LABEL” would become “DEFAULT_TEXT”
In BeanShell replacement mode, the search string is replaced with the return value of a BeanShell snippet. The following predefined variables can be referenced in the snippet:
_0
-- the text to be
replaced
_1
- _9
--
if regular expressions are enabled, these contain the
values of matched subexpressions.
BeanShell syntax and features are covered in great detail in Part III, “Writing Macros”, but here are some examples:
To replace each occurrence of “Windows” with “Linux”, and each occurrence of “Linux” with “Windows”, search for the following regular expression:
(Windows|Linux)
Replacing it with the following BeanShell snippet:
_1.equals("Windows") ? "Linux" : "Windows"
To convert all HTML tags to lower case, search for the following regular expression:
<\S+
Replacing it with the following BeanShell snippet:
_0.toLowerCase()
To replace arithmetic expressions contained in curly braces with the result of evaluating the expression, search for the following regular expression:
\{(.+?)\}
Replacing it with the following BeanShell snippet:
eval(_1)
These examples only scratch the surface; the possibilities are endless.
If the
check box in the search and replace dialog box is selected, clicking lists all occurrences of the search string, instead of locating the next match.By default, HyperSearch results are shown in a floating window. This window can be docked using the commands in its top-left corner popup menu; see the section called “Window Docking”.
If the
check box is selected in the results window, past search results are retained.Running searches can be stopped in the
> > dialog box.Search and replace commands can be performed over an arbitrary set of files in one step. The set of files to search is selected with a set of buttons in the search dialog box.
If the
button is selected, only the current buffer is searched. This is the default behavior.If the Appendix D, Glob Patterns for more information about glob patterns.
button is selected, all open buffers whose names match the glob pattern entered in the text field will be searched. SeeIf the
radio button is selected, all files contained in the specified directory whose names match the glob will be searched. The directory to search in can either be entered in the text field, or chosen in a file selector dialog box by clicking the button next to the field. If the check box is selected, all subdirectories of the specified directory will also be searched. Keep in mind that searching through directories containing many files can take a long time.The Appendix C, History Text Fields for details.
and text fields remember previously entered strings; seeWhen the search and replace dialog box is opened, the directory and file name filter fields are set to their previous values. They can be set to match the current buffer's directory and file name extension by clicking
.Note that clicking the
or radio buttons also selects the check box since that is what you would want, most of the time. However, the check box can be unchecked, for stepping through search results in multiple files one at a time.Two convenience commands are provided for performing multiple file searches.
C+e C+b
) displays
the search dialog box and selects the button.
C+e C+d
)
displays the search dialog box and selects the
button.
The search bar feature provides a convenient way to search in
the current buffer without opening the search dialog box. The search
bar does not support replacement or multiple file search. Previously
entered strings can be recalled in the search bar with the
Up
and Down
arrow keys; see Appendix C, History Text Fields.
By default, the search bar remains hidden until one of the quick search commands (described below) is invoked; however you can choose to have it always visible in the the section called “The View Pane”.
pane of the > dialog box; seeC+COMMA
) displays the
search bar if necessary, and gives it keyboard focus.
A+COMMA
) behaves
like the above command except it places the word at the caret in the
search string field. If this command is invoked while there is a
selection, the selection is placed in the search string
field instead.
Unless the ENTER
and S+ENTER
searches for the next and previous occurrence, respectively. Once
the desired occurrence has been located, pressing
ESCAPE
returns keyboard focus to the text area.
Unless the search bar is set to be always visible (see above),
pressing ESCAPE
will also hide the search
bar.
Incremental searches cannot be not recorded in macros. If your macro needs to perform a search, use the search and replace dialog box instead. See Chapter 8, Using Macros for information about macros.
C+PERIOD
) displays the
search bar if necessary, gives it keyboard focus, and selects the
check box. If this command is
invoked while there is a selection, the selected text will be
searched for immediately and the search bar will not be
shown.
If the Enter
in the search string field
will perform a HyperSearch in the current buffer.
A+PERIOD
) performs a
HyperSearch for the word at the caret. This command does not show
the search bar or give it keyboard focus.