简体   繁体   English

eclipse设置以自动重命名类文件

[英]eclipse setting to auto rename class files

I am looking for a setting in eclipse, where, if I right click and rename the file, then the content of the file as well gets changed to mirror the new name. 我正在eclipse中寻找设置,如果我右键单击并重命名文件,则文件的内容也会更改为镜像新名称。

Say I had a class called 说我有一堂课

public ClasA{

}

I right click the file called ClasA.java and rename it to ClassA.java. 我右键单击名为ClasA.java的文件,然后将其重命名为ClassA.java。 I would like my class in the source file to be renamed as follows 我希望将源文件中的类重命名如下

public ClassA{

}

The same with packages as well. 包也一样。 If I change the location of a source file to a different package, I would like the package sourcecode.location; 如果将源文件的位置更改为其他程序包,则需要该package sourcecode.location; as well to change accordingly. 以及相应地进行更改。

For some reason, I'm having to rename this in the current eclipse. 由于某种原因,我不得不在当前的日食中重命名它。 Can someone tell me where the setting is. 有人可以告诉我设置在哪里。

Press shift + alt + R to Refactor. Shift + Alt + R进行重构。 Please check Eclipse documentation for more options. 请检查Eclipse文档以获取更多选项。

The shortcut for renaming is alt + shift + R . 重命名的快捷方式是alt + shift + R。 You can rename any class, method, or variable and Eclipse will update all places where it is used. 您可以重命名任何类,方法或变量,并且Eclipse会更新使用它的所有位置。

To get used to it at first you can Right Click -> Refactor ( alt + shift + t ). 首先,您可以右键单击->重构( alt + shift + t )来习惯它。 It will show you the options like renaming, moving package, etc. Any action done through that many will update all corresponding references in your project. 它将向您显示诸如重命名,移动包等选项。通过许多操作完成的任何操作都会更新项目中所有相应的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM