Eclipse : 在 Eclipse IDE 下只搜索一个特定的词

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11826231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:46:23  来源:igfitidea点击:

Eclipse : search for only a particular word under Eclipse IDE

eclipse

提问by Pawan

Is it possible to search for only a particular word under Eclipse IDE . For example i need to search for a word "sub" .

是否可以在 Eclipse IDE 下仅搜索特定单词。例如,我需要搜索一个词 "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 .

但问题是,当我按 ctr l + H 并输入“sub”这个词时,它会产生所有匹配的结果,例如 submit ----etc ,但我想要在我的“搜索”中输入“sub”这个词。

Please let me know if its possible ??

请让我知道它是否可能?

Thanks in advance .

提前致谢 。

回答by Ashutosh Jindal

Try using regular expressions in the File Search Dialogue (Ctrl + H). You can use the word boundariesmodifier \blike so :

尝试在文件搜索对话框 (Ctrl + H) 中使用正则表达式。您可以像这样使用word boundaries修饰符\b

Eclipse Regular Expression Search

Eclipse 正则表达式搜索

\bsub\basks eclipse to search for all matches in which sub is both followed and preceded by a word boundary. Read more about word boundaries here.

\bsub\b要求 eclipse 搜索所有在 sub 后面和前面都有单词边界的匹配项。在此处阅读有关字边界的更多信息。

Here is a sample snapshot of the Search Results using the above:

以下是使用上述内容的搜索结果的示例快照:

Word Boundaries Search

词边界搜索

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.

如果您想将搜索限制为当前项目,请尝试选择“封闭项目”单选选项。如果您还没有打开项目中的文件,则此选项将被禁用。为了摆脱这种烦恼,我建议仅使用感兴趣的项目创建一个工作集,然后限制对该工作集的搜索。

回答by aleroot

You can do it from Find/Replace menu (CTRL+F) and flagging the Whole wordoption :

您可以从“查找/替换”菜单 ( CTRL+F) 并标记“全字”选项来执行此操作:

Find Replace

查找替换

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.

否则,从标准搜索菜单 ( CTRL+H) 中,您可以使用适当的正则表达式获得相同的结果,在您的情况下,您只需要在子文本之后(或/和之前)附加一个空格,您将只获得整个单词。

回答by Joydeep Roy

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

选择单词,然后按Ctrl+Alt+letter(G)它将搜索使用它的单词。