Eclipse provides cool short cut key for renaming the variables across within a class or entire workspace. If you are not aware of this feature, you would use “find” option and replace the variable with new name. But, this will lead to a problem of not renaming all the references. You can easily rename the variables by typing the short cut ALT + SHIFT + R in your Eclipse. There are two ways to to this:
- Move the curson over variable name and type CTRL + 1 for quick fix which would suggest the option to change the variable in a file or workspace. You just select the desired one to start rename the variable.
- Second option is to directly type ALT + SHIFT + R to rename the variable.
Look at the below screenshots which clearly describes how to do the renaming.
1. Short Cut Key : CTRL + 1
When you type the short cut key CTRL + 1, it will display the suggestion box like this one below.
2. Short Cut Key : ALT + SHIFT + R
When you type the short cut key ALT + SHIFT + R, it will change the editor like shown below to allow the editing variable names.