[英]Eclipse Shortcut to add access specifier to all fields?
I am not sure could be silly, but far important for me set find out shortcuts to add say "private" key words to all the Member Variables in java class. 我不确定这可能很愚蠢,但是对我来说重要的是设置查找快捷方式,以向Java类中的所有Member Variables添加“ private”关键字。
I followed so many links, but did not find any satisfactory answers : https://www.codejava.net/ides/eclipse/25-eclipse-shortcut-keys-for-code-editing . 我跟踪了很多链接,但没有找到任何令人满意的答案: https : //www.codejava.net/ides/eclipse/25-eclipse-shortcut-keys-for-code-editing 。
I have almost 40+ fields in Pojo class and none of the field has access specifier. 我在Pojo类中有近40多个字段,并且没有一个字段具有访问说明符。
Could anyone please suggest shortcut for the same? 有人可以建议同样的快捷方式吗?
student.java student.java
public class Student {
String id;
String name;
String clz;
.......
.......
........
}
This is for Eclipse on Windows/Linux. 这适用于Windows / Linux上的Eclipse。
1) Press alt + shift + A to Toggle block selection (Toggle block / column selection in the current text editor) , this will allow you to write vertically in Eclipse. 1)按alt + shift + A 切换块选择 (当前文本编辑器中的块/列选择) ,这将允许您在Eclipse中垂直编写。
2) Put the cursor at the beginning of the first line, then press shift key and move the cursor down with the ↓ key to select the lines you want to provide modifier, like this. 2)将光标放在第一行的开头,然后按shift键并使用↓键向下移动光标,以选择要提供的修饰符的行,如下所示。
3) Type in the modifier: 3)输入修饰符:
For Macos, the key combination for multi-line edits in Eclipse is option/alt + command + A 对于Macos,在Eclipse中用于多行编辑的组合键是option / alt + command + A
You can use find and replace
您可以使用
find and replace
Just mark your linke line this; 只需在您的链接行上标记此即可;
^ String^ id;
String name;
mark range is between ^
and ctrl+f
to find (if I am not mistaken and didnt confused that with intellij) 标记范围在
^
和ctrl+f
之间找到(如果我没有记错的话,并且没有与intellij混淆)
use find and replace to find Strign
and replace with private String
使用find和replace查找
Strign
并使用private String
替换
if you have not only Strings
here you can use reges to replace ^\\\\s+
with private
. 如果您不仅在这里有
Strings
,还可以使用reges将^\\\\s+
替换为private
。 That regex matches begining of the line and bland any number of blank characters. 该正则表达式匹配该行的开头,并且可消除任意数量的空白字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.