簡評:對于我自己來說,既有 PC 也有 Mac,并且都會有編程的需求,也會用到多種 IDE,EditorConfig 確實幫我擺脫了重復設置代碼規范這件麻煩事。
現在已經 2017 年了,但還是有很多人陷入在 tabs vs spaces 之類的爭論中。不是每個人都在嚴格要求自己的代碼規范和風格,對于多人協作的項目這容易出現問題,畢竟每個人所用的 IDE 和編輯器都可能不同。
這里就要介紹下 EditorConfig 了,你只需配置一個 .editorconfig 文件,在其中設置好要遵守的代碼規范,放在項目的根目錄下,就能夠在幾乎所有的主流 IDE 和編輯器中復用了,可以將 .editorconfig 文件也提交到版本控制系統中,就不需要針對不同 IDE 和編輯器再單獨進行設置了。
目前無需插件直接支持的有:
![Uploading 0_957798.jpg . . .]
插件列表:EditorConfig Download a Plugin
語法也很簡單,這是一個簡單的例子:
# indicate this is the root of the project
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
indent_size = 2
[*.html]
indent_size = 4
max_line_length = 80
[*.md]
trim_trailing_whitespace = false
目前支持的屬性:EditorConfig-Properties
當然如果你使用的工具不在以上的話,可以自己開發一個插件,官方也有相應的教程:
https://github.com/editorconfig/editorconfig/wiki/Plugin-How-To
官方網站:EditorConfig
目前在使用 EditorConfig 的項目已經有包括 jQuery, LibreOffice, Node.js, Ionic 等在內的數十個知名項目。
具體項目列表可以看看:editorconfig/projects
擴展閱讀:
2016 開發者工具年度熱門盤點
歡迎關注: