How can I convert tabs to spaces in every file of a directory?

后端 未结 19 1279
既然无缘
既然无缘 2020-12-02 03:48

How can I convert tabs to spaces in every file of a directory (possibly recursively)?

Also, is there a way of setting the number of spaces per tab?

19条回答
  •  失恋的感觉
    2020-12-02 04:13

    You can use find with tabs-to-spaces package for this.

    First, install tabs-to-spaces

    npm install -g tabs-to-spaces
    

    then, run this command from the root directory of your project;

    find . -name '*' -exec t2s --spaces 2 {} \;
    

    This will replace every tab character with 2 spaces in every file.

提交回复
热议问题