Skip to content

Instantly share code, notes, and snippets.

@lincolnge
Last active November 10, 2016 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lincolnge/2645017567a3c8d7f528819bb4040f6d to your computer and use it in GitHub Desktop.
Save lincolnge/2645017567a3c8d7f528819bb4040f6d to your computer and use it in GitHub Desktop.
把 tab 改成 space 的脚本
# 一个 tab 转为两个空格
tabToTwoSpaces() {
find . -name '*.js' | grep -v 'node_modules\|build' | awk '{print $1}' | xargs sed -i '' $'s/\t/ /g'
}
# 四个空格转换为两个空格。
FourSpacesToTwoSpaces() {
# sed -i '' -e $'s/ /\t/g' -e $'s/\t/ /g' filename.js
find . -name '*.js' | grep -v 'node_modules' | awk '{print $1}' | xargs sed -i '' -e $'s/ /\t/g' -e $'s/\t/ /g'
}
@lincolnge
Copy link
Author

lincolnge commented Nov 9, 2016

NodeJS 版(一个 tab 转为两个空格):https://github.com/zilong-thu/tabs-to-spaces/blob/master/app.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment