Eclipse Version: 2018-12
问题:使用快捷键插入单行注释(Shift + /)每次自动靠左,如下图

解决方案:
1、Window-->Preferences搜索line comment,选中Formatter中的Edit对当前Formatter进行修改

2、选中Enable line comment formatting以及Format line comments on first column,然后Apply

3、注意,修改后按Shift+/或者Shift+Ctrl+C插入单行注释仍然会自动靠左
此时按Shift+Ctrl+F格式化代码块就好了
写在后面:
以前版本的Eclipse,进入 Settings -> Code Style -> Java ,
在右边选择 “Code Generation” Tab,然后找到 Comment Code 那块,把
Line comment at first column
Block comment at first column
去掉前面两个的复选框即可,新版本未找到。
目前暂未找到修改后直接按快捷键插入单行注释不自动靠左的方法,如过有知道的,麻烦告知,先谢过了~
博客围绕Eclipse 2018 - 12版本展开,指出使用快捷键插入单行注释自动靠左的问题,并给出解决方案,即通过Window -> Preferences修改Formatter设置,修改后需按Shift + Ctrl + F格式化代码块。还提及旧版本的修改方式,新版本未找到对应设置。
1571





