Eclipse : search for only a particular word under Eclipse IDE - eclipse

Is it possible to search for only a particular word under Eclipse IDE .
For example i need to search for a word "sub" .
But the problem is that , when i did ctr l + H and typed the word "sub" , it producing all matching results such as
submit ----etc , but i want the exact word "sub" in my Search .
Please let me know if its possible ??
Thanks in advance .

Try using regular expressions in the File Search Dialogue (Ctrl + H). You can use the word boundaries modifier \b like so :
\bsub\b asks eclipse to search for all matches in which sub is both followed and preceded by a word boundary. Read more about word boundaries here.
Here is a sample snapshot of the Search Results using the above:
If you want to restrict the search to the current project then try selecting 'Enclosing Projects' radio option. This option will be disabled if you don't already have a file from the Project opened. To get past this annoyance, I would recommend creating a Working Set with just the project(s) of interest and then restricting the search on that Working Set.

You can do it from Find/Replace menu (CTRL+F) and flagging the Whole word option :
Otherwise from the standard Search menu(CTRL+H) you can achieve the same result using an appropriate regular expression, in your case you just need to append a space after(or/and before) the sub text and you will get only the whole word.

Select the word and then press Ctrl+Alt+letter(G) it will search the word where it is used.

Related

Partial autocomplete of the suggestions given by vscode?

Is it possible for the autocomplete feature of vscode to accept only part of the suggestions on Tab?
Basically, we can specify the word separators characters in settings but the autocomplete feature seems to ignore these and replace the complete full word either way.
What I want, for example, is that by specifying the word separator "_" the autocomplete won't replace the full suggestion but only until this character which should effectively be considered the end of the word.
For example, having semi_completions_foo() declared and having written only the initial "se".
"se" + Tab -> "semi_"
"semi_" + Tab -> "semi_completions_"
On the other hand by pressing Enter the full suggestion would be accepted.
"se" + Enter -> "semi_completions_foo"
Is this already implemented?
This is currently not supported by default as of VS Code 1.35 but is tracked by this feature request.
However VS Code does support tabbing through suggestion alternatives after you accept a completion with tab. Just press tab again to switch to the next suggestion from the list.

Is there why to change direction by hotkey in Eclipse search?

When we find something in Eclipse we use Ctrl+F and find the word.
But the Direction search option is so annoying, I want bi-direction search not forward or backward.
Is there way to change the option?
Using Ctrl + H ( Or Search -> File) you can search a file in File name patterns and search will return occurrences in all file.
Also you can mark what you want to search and then click Search -> Text - File and you will get it.

In Eclipse, how can you search within a search result?

"Long live the Unix Pipes".
Since I am working with Eclipse IDE, I would like to perform search within search results. Is that possible? How can I do that?
Ex:
Search for references of User (class).
> Search for validation in this result.
> Finally, search for specific pattern.
This is possible in Eclipse, well as far as the version I am using which is Eclipse Juno 4.2.2; I've used this extensively for impact analysis.
For example:
Search using "File Search" with criteria "employee"
The results will appear in the Tab "Search", assuming you are in the tree view (by default), click the root folder
Again, use the "File Search" this time using the 2nd criteria, for example "default" and making sure to click the Selected resources radio button
Effectively, this searches the keyword "default" from the previous search results produced by searching "employee".
Is it really required?. If you are searching any key in the search results then why don't you use it as search key in previous search itself?.
Eclipse search supports regular expression so you can use multiple search words likes key1 or key2 or key1 and key2 etc to narrow the search results.
Refer this Eclipse File Search Dialog - Regular Expression for Group Unions and Negation
However
You can search in search results with the help of some plugins check here. Take a look at Insta search and glance(Suites for your need) plugin.
Search result can also be exported with the help of this plugin
You cannot. And I am 99% sure of this.
But, just for your info, you can do reference search by pressing Cntrl + G on class name, or method name.

Simple eclipse search problem

I use the eclipse File Search option very much to search all files in my workspace for a certain content. But how do I specify that it should only return hits from a fixed search criteria? As an example I would like to find all occurrences of the string:
com.mystuff.data
but I also get all the hits for:
com.mystuff.data.ui
How do I make a "this-string-only-search" when searching files in my workspace??
If I understand you correctly, Eclipse don't provide option to search exact word.
You can use regular expression for it.
You can use \bSearchKeyword\b to find exact word.
I suggest that you use regular expressions.
Here are the steps:
Select the checkbox "Regular expression" which is located beside the "Containing text" field.
In the "Containing text" field write: com.mystuff.data\D\W
Note that:
\D means "no digit"
\W means "no alphanumeric"
In case you would like to refine the regular expression, click Ctrl-SPACE, in order to get the regular expression assistance.
Hope this helps.
Best regards
Maybe slightly off-topic but this got me tripped and brought me here - maybe useful for somebody else:
In the Eclipse standard Find/Replace dialogue the section 'Options' (that includes the option 'Whole Word') may be hidden if the Find/Replace dialogue window was previously resized to a smaller size, without any clue to its presence. Resizing it larger brings back the options section. See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=355206
and attached shots.
Eclipse standard Find/Replace dialogue search for Whole Word regards several characters (including period) besides a space as a word delimiter, so you indeed cannot distinguish between "com.mystuff.data" and "com.mystuff.data.ui"
E.g. search 'Stack' with option 'Whole Word' checked:
will match:
Stack
Stack overflow
Stack.overflow
Stack,overflow
Stack[overflow]
Stack(overflow)
Stack-overflow
Stack/overflow
will not match:
Stackoverflow
Stack2overflow
Stack_overflow
Simplest way is to add space in the start and end of your search term.
Try SHFT+ CTRL+R, then on right upper angle select Working Set, then name and specify your resources.
Create Work Set as above, then CTRL+H check checkbox All occurency, then select your Work Set. Or maybe you can create work set in CTRL+H.

How to search and replace 2 lines (together) in Eclipse?

I would like to search multiple files via eclipse for the following 2 lines:
#Length(max = L_255)
private String description;
and replace them with these two:
#Length(max = L_255, message="{validator.description.len}")
private String description;
Another tip on how to get the regex for a selected block.
Open one of the files that contains the multiple lines (multiline) to search or replace.
Click Ctrl+F and select "Regular expression". Close the Find/Replace window.
Select the block you need and click again Ctrl+F to open the Find/Replace window.
Now in the Find text box you have the regular expression that exactly matches your selection block.
(I discovered this, only after creating manually a regexp for very long block :)
Search are multi-line by default in Eclipse when you are using regex:
(\#Length\(max = L_255)\)([\r\n\s]+private)
I would like to add "private String description;"
(\#Length\(max = L_255)\)([\r\n\s]+private\s+?String\s+description\s*?;)
replaced by:
\1, message="{validator.description.len}")\2
It works perfectly in a File Search triggered by a CTRL-H.
As mentioned in Tika's answer, you can directly copy the two lines selected in the "Containing Text" field: those lines will be converted as a regexp for you by Eclipse.
CTRL+H does take two lines if you use regexp (and you don't have to write the regexp by yourself, eclipse does that for you).
Select your lines.
Click CTRL+H. The search dialog opens up.
If "Regular expression" is already checked, eclipse will have converted the two lines you search for into regexp for you, click Search.
If "Regular expression" if not already checked", check it and click Cancel (eclipse remembers your choice).
Select your lines again.
Click CTRL+H. The search dialog opens up. This time "Regular expression" is already selected. eclipse will have converted the two lines you search for into regexp for you, click Search.
A quick tip for including multiple lines as part of a manually constructed regular expression:
Where you would normally use .* to match any character zero or more times, instead consider using something like (?:.|\r?\n)*. Or put an extra ? at the end to make it non-greedy.
Explanation: . doesn't match new lines so need to do an "either-or": The parentheses match either the . before the pipe or the new line after it. The ? after \r makes the carriage return before the line feed optional to allow Windows or Unix new lines. The ?: excludes the whole thing as a capturing group (which helps to avoid a stack overflow).
Click Ctrl + F and select "Regular Expression" and then search the lines. In case to perform the same on multiple files, click Ctrl + H, click on 'File Search' and perform the same.
Select the folder that contains all your files and press Ctrl+H.