Skip to content

Instantly share code, notes, and snippets.

@fredrikhenne
Forked from mpereira/denoobinize.md
Created July 25, 2011 02:24
Show Gist options
  • Save fredrikhenne/1103431 to your computer and use it in GitHub Desktop.
Save fredrikhenne/1103431 to your computer and use it in GitHub Desktop.

Remove trailing whitespace, convert tabs to spaces and file format to unix (remove ugly ^M carriage returns) from files using a single command:

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' FILES

You could get your FILES using find

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' $(find scripts -name '*.sh' -type f)

If in doubt, ask man.

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