在 eclipse 中使用 快捷鍵 Ctrl + Shift + F 可以進行 format 操作。以下將進行相關的設置。
1. format 時 code style 的設置
這裡的format 可以進行設置,新建一個自己的code style:
Window-->Preferences --> Java--> Code style --> Formatter
2. 保存時自動format
也可以在保存的時候自動format,設置的地方為:
Window-->Preferences -->java->editor->Save Actions->Format Source Code
取消勾选,即取消了保存时自动格式化的功能。