Legal Notice
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no "Invariant Sections", "Front-Cover Texts" or "Back-Cover Texts", each as defined in the license. A copy of the license can be found in the file COPYING.DOC.txt included with jEdit.
Table of Contents
List of Examples
The Extended Search plugin provides extensions of the search and replace function of the jedit text editor.
It doesn't extend the search bar, which is a view related feature
It includes all the standart search and replace functions described in jEdit user guide.
The Extended Search Dialog is an extension of the core search-and-replace dialog
The regular expression support helps you to construct a regular expression. If you select from the popup menu, the according RE is inserted in the search field or in the replace field at the caret position. Any selected text is replaced.
Exceptions:
Brackets are inserted around the selection
The action "escape string" adds an escape to all RE relevant characters in the search string
Search for all occurances of the search string in the current buffer, according to the current settings.
All matches are selected, and a match counter is displayed.
Restriction: only applicable for the current buffer
Resets search settings to default values
When checked, the search directory is the directory of the current buffer
Start searching from top of buffer.
Note: "refind" will search for the next occurance, as long as no search settings are changed
"backward search" is available for regular expressions, too.
whole word: matches only complete words (according to regular expressions convention)
prefix: matches only words with the search string as prefix
suffix: matches only words with the search string as suffix
Restriction: combination with option "regular expression" is not supported
Search for all occurances of the search string in the given column range
expandTabs: if selected, tabs are expanded to the visible size. Otherwise, tabs are treated as 1 space
left col: left range, line begins with '1' (as displayed in status bar)
right col: right range, must be > left col + length(search string) (if no regexp). If right col is omitted, it is calculated automatically, to right col = left col + length(search string)
Search for all occurances of the search string in the given row range
upper row: upper range, first line begins with '1' (as displayed in status bar)
lower row: lower range, must be >= upper row
Hints:
If multiple lines are selected before invoking the search dialog, the upper / lower rows are predefined with the selected line range.
Row search allows "find all" and "replace&find" only inside the specified line range.
inside folds: matches only text inside of a fold
outside folds: matches only text outside of a fold
Restriction: not applicable for hypersearch
inside comments: matches only text inside of a comments
outside comments: matches only text outside of a comments
Note: "comment search" in the current buffer uses identifies comments according to the definition in the according edit mode. For hypersearch, this is not possible. Therefore, the comment indicators are defined in XSearch.props.
This checkbox toggles
the hyper search feature (unchanged to the standard implementation)
the hyper replace feature, if allowed according to the global options
This feature is an extention to the hyper search facility. If hyper search is invoked, the matching lines are displayed in the hyper search window, and additionally the surrounding lines before (up) and after (down) the match.
Tip: extremly useful if you search where a method is called and which parameters, specified in the next lines, are used.
Tentativ search uses a search algorithm which tolerates following type mismatching.
double typed char (toown instead of. town)
dash instead of underscore (Fast-Macro instead of Fast_Macro)
combination with option "regular expression" is not supported
Example: You search "My_Bsh_Macro" but you enter the search string Myy_Bsh-mmacro
Tentativ search performs a search with the regexp "My+_Bsh[-_]m+acro"
If enabled, all search settings which apply to a certain search string are memorized.
If you recall a search string of the History Text Field , its last settings (inclusiv search directory) are active in the xsearch and replace dialog.
Hide or show the search | replace | extended options.
If a non-default option is selected but not visible, it is displayed in a line below "show options"
If Replace and Find is invoked
and nothing is selected, the first occurance of the search string will be replaced by the replace string
the search dialog is kept as long as 'keep dialog' is not switched off explicitely
Note: The hyper search results are displayed in the dockable window "XHyperserarch". In the context menu, you have the options:
expand all subnodes of the selected node
collapse all subnodes of the selected node
expand exactly 1 sublevel of the selected node
expand exactly 2 sublevel of the selected node
expand all nodes
collapse all nodes
writes the hypersearch result of the selected node to a new buffer
writes the hypersearch result of all nodes to a new buffer
Displays the xsearch-and-replace dialog box
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 (standard behaviour).
Performes a search with the previously used search string, taking in account the current search options, without displaying the xsearch-and-replace dialog.
Same as xfind-refind, but the search starts from the top of the document. The search string is the current selection or, if nothing is selected, the previous search string.
Same as xfind-refind, but the search direction is forward. The search string is the current selection or, if nothing is selected, the previous search string.
Same as xfind-refind, but the search direction is backward. The search string is the current selection or, if nothing is selected, the previous search string.
Performes the last replace action for all occurances of the search string in the current selection.
Repeats the last replace action
Performes the last replace action for all occurances of the search string in the current document.
Displays the xsearch-and-replace dialog box.
The options "hypersearch" and "search in directory" are already selected (standard behaviour).
Performes a search without displaying the xsearch-and-replace dialog, ignoring the current search settings.
The search string is:
the current selection, if a single selection exists
the word at the caret, if the caret is at a word. In this case, a "whole word search"is performed
If no valid search string is found, the xsearch-and-replace dialog is displayed with standart settings.
Same as quick-xfind-standard-options, but a hypersearch in the current buffer is performed.
Same as quick-xfind-standard-options, but a hypersearch in all open buffers is performed.
Same as quick-xfind-standard-options, but the current options are used.
Same as quick-hypersearch-standard-options, but the current options are used.
Note: When using quick-search, the user is often not aware of the current search settings. Therefore, only quick search with standard options is recommended
After a search with regular expressions, you can obtain the subexpressions
Method: String[] xsearch.XSearchAndReplace.getMatchedSubexpressions(String <matched String>) or String xsearch.XSearchAndReplace.getMatchedSubexpressions(String <matched String>, int <number of subexpression>) |
Example 5.1. get subexpressions
xsearch.XSearchAndReplace.setSearchString("(^\\* SYNTAX - ERRORS : *)([1-9]+)");
if (xsearch.XSearchAndReplace.find(view))
String[] subExp =
xsearch.XSearchAndReplace.getMatchedSubexpressions(textArea.getSelectedText());
|
Resets search settings to default values
Execution: xsearch.SearchSettings.resetSettings()
Saves the current search settings on a stack. Useful if you don't want to overwrite the settings during macro run Execution: xsearch.SearchSettings.push();
Restores the last pushed search settings. Execution: xsearch.SearchSettings.pop();
To manipulate all matches inside the current buffer, "findAll" selects all matches. With the method "textArea.getSelectedLines()", they can be manipulated.
Example 5.2. Delete all lines containing a string
xsearch.SearchSettings.push();
xsearch.SearchSettings.resetSettings();
xsearch.XSearchAndReplace.setSearchString("jEdit ist doof");
xsearch.XSearchAndReplace.setSearchFileSet(new CurrentBufferSet());
xsearch.XSearchAndReplace.setFindAll(true);
xsearch.XSearchAndReplace.find(view);
int[] lines = textArea.getSelectedLines();
for (int i=lines.length-1;i>=0;i--) {
textArea.moveCaretPosition(buffer.getLineStartOffset(lines[i]));
textArea.deleteLine(); }
xsearch.SearchSettings.pop();
|
When you write macros or plugins which invoke search very often, updating the textarea is time consuming. For better performance, highlighting of the search match can be disabled (flag "silent"=xsearch.XSearchAndReplace.FIND_OPTION_SILENT (true) when calling "find")
find(View view, Buffer buffer, int start, int end, boolean firstTime, boolean reverse,
boolean silent) |
The result of the last search is obtained from method "getLastMatchedSelection"
Example 5.3. Silent search
xsearch.SearchSettings.push();
xsearch.SearchSettings.resetSettings();
xsearch.XSearchAndReplace.setSearchString("target");
if (xsearch.XSearchAndReplace.find(view, buffer, 0, buffer.getLength(), false, false,
xsearch.XSearchAndReplace.FIND_OPTION_SILENT))
//do something with xsearch.XSearchAndReplace.getLastMatchedSelection()
xsearch.SearchSettings.pop();
|
It is possible to tailor the layout of the xsearch-and-replace dialog box. Disable features you will "never" use. They won't consume any space on the xsearch-and-replace dialog.
Further options:
Hyper replace ("hyper search enables hyper replace, too")
If this option is selected, the checkbox "hyper search" toggles the feature "hyper replace", too.
"Hyper replace" is activated when invoking "replace all".
It displays all changed lines in the hyper search window.
The default replace implementation in jEdit is case sensitiv, that means that 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 (see jEidt user guide: "Replacing text").
If this behavious is not required, you can switch it off in the Extended Search global options
Toggles the font used for the search and replace textareas. The textArea font is usually fixed width, therefore better readable.
This is especially useful when developping regular expressions.
You can write to:
Rudi Widmann <rudi.widmann@web.de>
The jEdit-users mailing-list <jedit-users@lists.sourceforge.net>
The jEdit-devel mailing-list <jedit-devel@lists.sourceforge.net>
Version 1.0.7. Requires JDK 1.4, jEdit 4.2
Adapted documentation to docbook standard
Implement RE support button
Add action "write result to buffer" to the context menu of XHypersearch result
Version 1.0.6. Requires JDK 1.4, jEdit 4.2
Add extended functions to the context menu of XHypersearch result
Adaption to jEdit 4.2 deferred plugin loading
Version 1.0.0. Requires JDK 1.4, jEdit 4.1
Final release for jEdit 4.1