简体   繁体   English

Grunt将缩进转换为空格

[英]Grunt convert indentation to spaces

Is there a grunt task to convert all file indetations from tabs to spaces? 是否有艰巨的任务将所有文件索引从制表符转换为空格? I've tried to looking but the ones I found only lint the files or just don't work well. 我尝试查找,但发现的文件仅使文件变细或无法正常工作。 These are the ones I've tried: 这些是我尝试过的:

You may use github.com/jonschlinkert/grunt-prettify — I tested that plugin when I used GruntJS , so I know that it works fine). 您可以使用github.com/jonschlinkert/grunt-prettify —我在使用GruntJS时测试了该插件,所以我知道它可以正常工作。

the option you are looking for is indent_char 您正在寻找的选项是indent_char

Type : String Default value: ' ' (space) 类型 :字符串默认值:“”(空格)
Options : space|tab (use an actual space or tab, not the word) 选项 :空格|制表符(使用实际空格或制表符,而不是单词)
Character with which to indent the output HTML. 缩进输出HTML的字符。

I stumbled upon the exact same problem as you, as I had a project with mixed indentation (1 tab, 4 spaces and 2 spaces). 我偶然发现了与您完全相同的问题,因为我有一个带有混合缩进的项目(1个制表符,4个空格和2个空格)。 I ended up modifying grunt-indent to change from any style of indentation to the desired one (eg it converted all files to use 2 spaces). 我最终修改了grunt-indent,以将任何形式的缩进更改为所需的缩进样式(例如,它将所有文件转换为使用2个空格)。

npm install grunt-fixindent --save-dev
https://github.com/anton164/grunt-fixindent https://github.com/anton164/grunt-fixindent

Try this grunt task. 试试这个艰巨的任务。 This converts all files in directories recursively. 这将递归转换目录中的所有文件。

https://www.npmjs.com/package/grunt-convert-indent https://www.npmjs.com/package/grunt-convert-indent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM