How to rename/refactor a variable in Eclipse PDT in a Netbeans-like way
Asked Answered
F

2

12

In the NetBeans IDE, changing a variable name in the parameters of a function also changes all occurrences of that name in the function. How can I get that behavior with Eclipse PDT? There is a Refactor → Rename item in the context menu, but it let me refactor only the file name.

This issue has been open since 2006 and you can vote for it in the PDT bug tracker #149818.

Fillander answered 5/4, 2011 at 7:5 Comment(0)
M
4

Code refactoring presence is the difference between PDT and Zend Studio as it is shown at the comparison page. So no, there is no way to do code refactoring in PDT.

Millan answered 14/4, 2011 at 15:53 Comment(2)
But it may be supplied by some plugin. Zend Studio is paid product, developed by someone entirely different than PDT. So anyone can create a refactor plugin for PDT ;)Beverlybevers
Should be possible to make a pluginUseless
H
0

It is quite easy now, to do this in Eclipse for PHP Developers. My eclipse version is Mars.2 Release (4.5.2) Build Id: 20160218-0600.

You just need to put your cursor over the php variable you want to rename, then Right-Click your mouse and select Refactor -> Rename. As soon as you do that, you will straight away see that all the variables, with the exact same name, within that php function, are now selected. You just need to start editing the variable. It will also give you visual cue, how all them are changed simultaneously, while you are editing.

The php functions within a class (locally not globally) can also be changed in similar fashion.

I find it easy, to use the keyboard shortcut on my mac, by pressing Command + Alt + R

Note: Please don't highlight the variable name, otherwise it behaves weirdly.

Highhanded answered 12/8, 2016 at 5:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.