Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在编码时使用了很多方括号和大括号。无论是多次施法,还是在 if 块中施法多次,等等。我有时会迷失在括号中,而且讨厌放很多。是否有任何快捷键来格式化这个选定的代码部分?我试过 Ctrl-Shift-F,但这并没有给我想要的。注意:我在 Eclipse Mars 上工作。
你想要的是Source菜单| Cleanup,然后自定义配置文件以添加删除多余的括号。从Code Style选项卡检查Use parenthesis in expressions Only if necessary. 然后完成向导:
Source
Cleanup
Code Style
Use parenthesis in expressions
Only if necessary
这会改变:
super.start(((BundleContext)(context)));
到:
super.start(context);
另外,如果您愿意,您可以将项目设置为在保存时自动执行代码清理任务。
您是否尝试过 ctrl+3 并输入甲酸盐?对我来说 Ctrl-Shift-F 被其他应用程序绑定并导致 Eclipse 错过捕捉它。
搜索格式化程序Java->code style->formatter 有一个选项卡大括号。
Java->code style->formatter
如果您选择特定行并按Ctrl + Shift + Feclipse 将仅根据您的格式化程序格式化您选择的行。
Ctrl + Shift + F