使用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