使用Eclipse的時候通常對coding style有一定的要求,通常最主要的就是Java和xml檔案中tab和空格,Java格式的一些約定俗成的東西,把自己的常用設定儲存在github上面,留個備份:Workspace設定
Windows->Preferences->General->Workspace text file encoding: UTF-8 New text file line delimiter: Unix Windows->Preferences->General->Editors->Text Editors select insert spaces for tabs select Show print margin (update pring margin column to 150) select Show line numbers select Show whitespace characters Windows->Preferences->XML->XML Files->Editor
For insert whitespace before closing empty end-tags, select Indent using psaces, change size to 4 Windows->Preferences->Java->Code Style->Formatter click New, input profile name click edit, change Tab policy to Space only, set Indentation/tab size to 4 Windows->Preferences->Java->Editor->Save Actions select Perform the selected actions on save select Format source code Format edited lines for old projects and Format al lines for new projects select Addional actions, click configure In Code Organizing select Remove trailing whitespace select correct indentation In Code Style select blocks in if/while/for/do with Always except for single return or throw select convert 'for' loops to enhanced select use parentheses in expressions select use modifier 'final' where possible select convert funtional interface instances with use lambda where possible In Member Accesses: select user 'this' qualifier for field accesses select user 'this' qualifier for method accesses select qualify field access and qualify method access In Unnecessary Code select Remove unused imports select Remove unused private members Remove unused local variables