Search>Find (shortcut: Control-F) displays the search and replace dialog box.
The search string can be entered in the Search for text field. This text field remembers previously entered strings; see Appendix C for details.
If 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 consists of multiple lines, the Search in Selection and HyperSearch buttons will be pre-selected, and the search string field will be blank.
The search can be made case insensitive (for example, searching for "Hello" will match "hello", "HELLO" and "HeLlO") by selecting the Ignore case check box.
Regular expressions may be used to match inexact sequences of text if the Regular expressions check box is selected; see Appendix E for more information about regular expressions. Note that regular expressions can only be used when searching forward.
Clicking Find will locate the next (or previous, if searching backwards) occurrence of the search string after the caret position. If the Keep dialog check box is selected, the dialog box will remain open; otherwise, it will be closed after the search string is located.
If no occurrences could be found and the Auto wrap check box is selected, the search will automatically be restarted and a message will be shown in the status bar to indicate that. If the check box is not selected, a dialog box will be displayed, offering to restart the search.
Search>Find Next (shortcut: Control-G) locates the next occurrence of the most recent search string without displaying the search and replace dialog box.
Search>Find Previous (shortcut: Control-H) locates the previous occurrence of the most recent search string without displaying the search and replace dialog box.
The replace string text field remembers previously entered strings; see Appendix C for details.
Clicking Replace & Find will perform a replacement in the current selection and locate the next occurrence of the search string. Clicking Replace All 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 result of a BeanShell script snippet. Two radio buttons in the search and replace dialog box can be used to choose between these behaviors, which are described below in more detail.
If the Text radio button is selected, the search string is 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 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, if you are searching for "label" and replacing it with "text", then the following replacements could be made:
"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, but here are some examples:
To convert all HTML tags to lower case, search for the following regular expression:
<(.*?)> |
Replacing it with the following BeanShell snippet:
"<" + _1.toLowerCase() + ">" |
To replace arithmetic expressions between curly braces with their result, search for the following regular expression:
\{(.+?)\} |
Replacing it with the following BeanShell snippet:
eval(_1) |
These two examples only scratch the surface; the possibilities are endless.
If the HyperSearch check box in the search and replace dialog box is selected, clicking Find will list all occurrences of the search string in the current search scope, instead of locating them one by one as an ordinary search would.
By default, HyperSearch results are shown in a floating window; the window can be set to dock into the view in the Docking pane of the Utilities>Global Options dialog box; see the section called "Window Docking".
Running searches can be stopped in the Utilities>I/O Progress Monitor dialog box.
Search and replace commands can be performed in more than one file at a time.
If the All buffers radio button in the search and replace dialog box is selected, all open buffers whose names match the glob pattern entered in the Filter text field will be searched. See Appendix D for more information about glob patterns.
If the Directory radio button is selected, all files in the directory whose names match the glob will be searched. The directory to search in can either be entered in the Directory text field, or chosen in a file selector dialog box by clicking Choose. If the Search subdirectories check box is selected, all subdirectories of the specified directory will also be searched. Keep in mind that searching through directories with many files can take a long time and consume a large amount of memory.
The Directory and Filter text fields remember previously entered strings; see Appendix C for details.
Two convenience commands are provided for performing multiple file searches.
Search>Search in Open Buffers (shortcut: Control-E Control-B) displays the search and replace dialog box, and selects the All buffers radio button.
Search>Search in Directory (shortcut: Control-E Control-D) displays the search and replace dialog box, and selects the Directory radio button.
The search bar at the top of the view provides a convenient way to perform simple searches without opening the search and replace dialog box first. Neither multiple file search nor replacement can be done from the search bar. The search bar remembers previously entered strings; see Appendix C for details.
Unless the HyperSearch check box is selected, the search bar will perform an incremental search. In incremental search mode, the first occurrence of the search string is located in the current buffer as it is being typed. Pressing Enter and Shift-Enter searches for the next and previous occurrence, respectively. Once the desired occurrence has been found, press Escape to return keyboard focus to the text area.
If the HyperSearch check box is selected, entering a search string and pressing Enter will perform a HyperSearch in the current buffer.
Search>Incremental Search (shortcut: Control-,) moves keyboard focus to the search bar. If text is selected when this command is invoked, the selection is inserted into the search bar automatically.
Search>Quick HyperSearch (shortcut: Control-.) moves keyboard focus to the search bar and pre-selects the HyperSearch check box. If text is selected when this command is invoked, a HyperSearch for that text is performed immediately.
The Search>Incremental Search for Word (shortcut: Alt-,) and Search>Quick HyperSearch for Word (shortcut: Alt-.) commands perform an incremental search and HyperSearch, respectively, for the word under the caret.
The search bar can be disabled in the General pane of the Utilities>Global Options dialog box.
Incremental searches cannot be not recorded in macros. Use the search and replace dialog box instead. See Chapter 7 for information about macros.