1. 程式人生 > >Intellij IDEA 程式碼格式化與eclipse共用

Intellij IDEA 程式碼格式化與eclipse共用

eclipse code formatter 安裝步驟:
1,安裝外掛:
網路安裝:選擇Setting =>Plugins=>Browse repositories,搜尋Eclipse即可出現,點選左上角的Download and Install安裝。安裝之後重啟Intellij,即可在Setting =>Eclipse Code Formatter找到配置項。
硬碟安裝(推薦):Setting =>Plugins=>Install plugin from disk,選中下載好的安裝包【EclipseFormatter.zip】安裝,重啟後生效;
2,配置外掛:
選擇Setting =>Eclipse Code Formatter,勾選Use the Eclipse-code-formatter,並在Eclipse Java Formatter config file選擇Eclipse用的code-style.xml檔案,這個選項會決定格式化程式碼的方式。
同時配置Import order的From File也為Eclipse用的code-style.xml檔案,這個選項會決定組織import區域的方式。
3,使用外掛
使用Intellij的格式化快捷鍵"Ctrl+ALT+L"即可進行格式化。如果出錯會輸出提示到Event Log裡,如果看到'xxx formatted sucessfully by Eclipse code formatter'則表示格式化成功。