How to rename/refactor a variable in Eclipse PDT in a Netbeans-like way
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开发者_如何学Python bug tracker #149818.
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.
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.
精彩评论