我有以下代码:
public int doBam(int bam) {
if(foo) {
bam += 1;
if(bar) {
bam += 1;
}
}
return bam;
}
我想注释掉 if(bar) ...
当我在 Eclipse 3.6 中切换注释时,我会得到这个:
public int doBam(int bam) {
if(foo) {
bam += 1;
// if(bar) {
// bam += 1;
// }
}
return bam;
}
我可以让 Eclipse 像这样切换注释吗?
public int doBam(int bam) {
if(foo) {
bam += 1;
//if(bar) {
// bam += 1;
//}
}
return bam;
}
最佳答案
Can I make Eclipse to toggle comment like this instead?
这是一个三步过程..
第 1 步:- 选择所需的代码。
if(bar) {
bam += 1;
}
第 2 步:- 按 Control + 7 或 Control +/
// if(bar) {
// bam += 1;
// }
第 3 步:- 按 Control + Shift + F
// if(bar) {
// bam += 1;
// }
更新
Also, when uncommenting, the Eclipse autoformatter does not restore the previous indentation
与评论一样,取消评论也是三步过程:-
- 选择
- 控制 +/
- Control + Shift + F
it applies it's own formatting rules instead.
您可以更改这些格式规则。 Windows --> 首选项 --> Java --> 代码样式 --> 格式化程序 --> 编辑 --> 注释选项卡。
Eclipse 不允许编辑默认的内置配置文件。创建新的配置文件并继承内置配置文件的所有属性,然后您可以自定义新创建的配置文件。
关于Eclipse 切换注释缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4225951/