使用 EditorConfig来规范代码缩进等的风格以webstorm为例
来源:互联网 发布:淘宝购物上传身份证 编辑:程序博客网 时间:2024/06/05 01:52
在项目开发过程中,有的人喜欢用tab来缩进,有的人喜欢用空格。为了保持缩进风格的一致,可以使用EditorConfig来规范缩进风格,缩进大小,tab长度以及字符集等。
Editorconfig项目由两部分组成,一个是.editorconfig 的文件格式(format),一个是editorconfig 插件(plugin)
Editorconfig使用.editorconfig文件来设置python,javascript文件的行尾和缩进风格。官方提供的示例代码如下。
# EditorConfig is awesome: http://EditorConfig.org# top-most EditorConfig fileroot = true# Unix-style newlines with a newline ending every file[*]end_of_line = lfinsert_final_newline = true# 4 space indentation[*.py]indent_style = spaceindent_size = 4# Tab indentation (no size specified)[*.js]indent_style = tab# Indentation override for all JS under lib directory[lib/**.js]indent_style = spaceindent_size = 2# Matches the exact files either package.json or .travis.yml[{package.json,.travis.yml}]indent_style = spaceindent_size = 2
使用的时候需要把.editorconfig放在项目目录里。
当打开文件的时候,editorconfig 插件就会在当前目录及上级目录寻找.editorconfig文件。
在很多开发工具中都可找到editconfig的插件。
官方文档可以在这个网站查看
http://editorconfig.org/
现在举例在webstorm中安装Editconfig的安装和使用
一.安装
1首先打开Webstorm然后选择Configure
2选择plugins
3选择browser repositories
4找到Editorconfig后右击选择Download and install,安装完成后重启webstorm
http://editorconfig.org/
二使用
在windows下使用时,在要使用editorconfig的项目目录里创建 .editorconfig. 的文件,这样系统会自动命名为.editorconfig
编码就会根据.editorconfig中指定的风格进行规范
具体查看文档解释。
0 0
- 使用 EditorConfig来规范代码缩进等的风格以webstorm为例
- 在WebStorm中使用editorConfig插件
- 良好的代码规范 -- 缩进
- 如何使用 Pylint 来规范 Python 代码风格
- 如何使用 Pylint 来规范 Python 代码风格
- 如何使用 Pylint 来规范 Python 代码风格
- 如何使用 Pylint 来规范 Python 代码风格
- 如何使用 Pylint 来规范 Python 代码风格
- 如何使用 Pylint 来规范 Python 代码风格
- 如何使用 Pylint 来规范 Python 代码风格
- 如何使用 Pylint 来规范 Python 代码风格
- 我的 React Native 技能树点亮计划 の 代码风格统一工具 EditorConfig
- 使用Eclipse插件来规范团队的编码风格
- 代码缩进风格
- 利用 vs2008 视警告为错误 的使用场景 可以达到 规范代码等作用
- [C++] 代码C风格缩进
- scala代码风格指南--<缩进>
- sublime text编辑器修改python代码的缩进设风格
- JS操作JSON
- ARM体系结构下面内存和i/o映射区别
- Linux中如何让进程(或正在运行的程序)到后台运行?
- Eclipse 配置 MinGW4.7.2
- android实现应用程序的开机自启动
- 使用 EditorConfig来规范代码缩进等的风格以webstorm为例
- git的基本操作原理
- CLONE数据库软件+手动安装数据库
- web代理 及 apache配置
- Java正则表达式中的十大问题
- 我的XMPP协议IM架构
- CloseableHttpClient加载证书来访问https网站(转载)
- windows下PyGTK开发环境配置
- 批处理文件