searching

Topics for the Eclipse Environment
Post Reply
roland.ames

searching

Post by roland.ames »

Is there a simple way to search for a string in the source code, when I only want to find the string as a whole word.

ie if I have a variable named "variable" and another named "variable1", I want to search / replace "variable" while leaving "variable1" unchanged.

the only way I can see is to use regular expressions and search for "/svariable/s".

I often want to find all occurences of "variable", replace them with "new_variable" without changing "variable1".

Is there an easy way to do this.

If you are familiar with CodeWright, it is searching with the "whole word" box selected.
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: searching

Post by Ridgeglider »

With the project saved (and ideally built successfully), try selecting the variable, right-clicking and hitting Refactor/Rename or ALT+Shift+R. When you do, a small box appears around the variable. When you hit enter, the changes apply to all instances. If the project was not previously built successfully, this process is can have issues because the map is not yet really intact.
roland.ames

Re: searching

Post by roland.ames »

Thanks for that tip, it does exactly what I want.
I have not used any of the refactoring functions before, but they look very useful.
I need to explore the Eclipse environment more, I'm sure there are other things in there that would save me time.
If you are aware of any good intro to eclipse docos I could read, please point me there.

Roland
Post Reply