1. windows=》preferences=》general=》editors=》text editors =》勾選 “insert spaces for tabs”
2. Java:windows=》preferences=》Java =》 Code Style =》 Formatter =》點擊右邊的Active profile 的Edit =》Indentation =》Tab Policy 選爲 Spaces Only,然後下面的Indentation size 和 Tab size 都設置成你要的空格數即可!一般是4個空格!!
3. JavaScript :windows=》preferences=》JavaScript =》 之後的步驟與Java一樣
4. C/C++ :windows=》preferences=》C/C++ =》 之後的步驟與Java一樣
5. PHP:windows=》preferences=》PHP =》Code Style =》 Formatter =》Tab Policy 選爲 Spaces ,Indentation size填4
6.Html :windows=》preferences=》Web =》HTML Files =》Editors =》選擇“Indent using spaces”,Indentation size填4
7.XML :windows=》preferences=》XML =》XML Files =》之後的步驟與Html 一樣
有些人可能想空格,用小圓點代替,方法: windows=》preferences=》general=》editors =》text editors=》選中“Show whitespace characters”
配置eclipse 格式化默認長度:
Window->Preferences->Java->Code Style->Formatter->Edit ->Line Wrapping->Maximum line width:默認80