jEdit Community - Resources for users of the jEdit Text Editor
Search for hi-lited word without openig the search dialog box?
Submitted by Anonymous on Thursday, 14 July, 2005 - 16:41
Is there a simple way to search for a hi-lited string without opening the search dialog box or search bar? I.e. I'd like to hi-lite a string and with a single button press have Jedit find the next occurance of that string.

Thanks!
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Try the following macro: I
by Anonymous on Thu, 14/07/2005 - 18:47
Try the following macro: If you have a selection, it will search forward for that, otherwise it selects and searches based on what is considered a word in the current buffer.
findNextOccurance(View view)
{
        String word = null;
        Selection[] selection = view.getTextArea().getSelection();
        if(selection.length == 0)
                view.getTextArea().selectWord();
        if(selection.length <= 1)
        {
                String word = view.getTextArea().getSelectedText();
                SearchAndReplace.setSearchString(word);
                SearchAndReplace.setAutoWrapAround(true);
                SearchAndReplace.setReverseSearch(false);
                SearchAndReplace.setIgnoreCase(false);
                SearchAndReplace.setRegexp(false);
                SearchAndReplace.setSearchFileSet(new CurrentBufferSet());
                SearchAndReplace.find(view);
        }
        else
                Toolkit.getDefaultToolkit().beep();

}

findNextOccurance(view);
-Ollie
 
Similar Macro
by Anonymous on Thu, 14/07/2005 - 21:32
This is my version, surely less efficient than Ollie's Smiling

//Macro Starts here
//Get the selection from the textArea

String searchString = textArea.getSelectedText() != null ? textArea.getSelectedText() : SearchAndReplace.getSearchString();

SearchAndReplace.setSearchString(searchString);
if(!SearchAndReplace.find(view, buffer, textArea.getCaretPosition())) {
//Not found. Try searching from top
SearchAndReplace.find(view, buffer, 0);
}
//Macro ends here
User login
Browse archives
« April 2025  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   107800
Context Free Art (*.cfdg)   0.31   46069
BBEdit scheme   1.0   18605
JBuilder scheme   .001   18505
ColdFusion scheme   1.0   18039
R Edit Mode - extensive version   0.1   17486
Advanced HTML edit mode   1.0   16220
Matlab Edit Mode   1.0   16084
jEdit XP icons   1.0   15243
XP icons for jEdit   1.1   14306