Ctrl + Shift + F:格式化當前文件或選中代碼塊。
路徑:Tools → Options → Editor → Formatting → Java
| 設定項 | 建議值 | 說明 |
|---|---|---|
| Expand Tabs to Spaces | 取消勾選 | 保留 Tab 字元 |
| Add Leading Start in Comment | 勾選 | 註釋行首自動加 * |
| Add NewLine Before Brace | 勾選 | 左大括號前換行(K&R 風格) |
| Add Space Before Parenthesis | 勾選 | if (condition) 括號前加空格 |
| Number of Spaces per Tab | 4 | Tab 顯示寬度 |
Properties → Formatting 切換。Save Actions(Editor → Save Actions)可在儲存時自動格式化、整理 Import、移除尾隨空白。.nbattrs 或共享 nbproject/private/ 設定,統一風格。