Last active
December 22, 2015 06:09
-
-
Save jakl/6428711 to your computer and use it in GitHub Desktop.
Remove trailing whitespace and convert tabs to 2 spaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Warning: Operates on binary files - make sure to have all files in git to revert them! | |
# remove trailing whitespace recursively in a repo | |
find . -type f -not -iwholename '*.git*' | xargs sed -i -r 's/[ ]+$//' # [] contains a space and a tab | |
# convert tabs to spaces: | |
find . -type f -not -iwholename '*.git*' | xargs sed -i -r 's/ / /g' # s/1/2/g ... 1 is a tab, 2 is two spaces | |
# revert binary files | |
git diff | grep Binary | sed 's/^Binary files a\///' | sed 's/ and .*$//' | xargs git checkout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment