Skip to content

Instantly share code, notes, and snippets.

@metaskills
Last active January 4, 2016 01:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save metaskills/8545940 to your computer and use it in GitHub Desktop.
Save metaskills/8545940 to your computer and use it in GitHub Desktop.
OS X Command To Clean All Whitespace From A Rails Project
find app config db spec test -type f -name '*.rb' -or -name '*.coffee' -or -name '*.erb' -or -name '*.jbuilder' -or -name '*.js' | xargs sed -i '' -E "s/[[:space:]]*$//" | xargs sed -i -E '$a\'
@metaskills
Copy link
Author

Make one big whitespace commit to avoid per developer settings. Then enable this in Sublime Text 2.

"ensure_newline_at_eof_on_save": true,
"trim_trailing_white_space_on_save": true,

Add or remove both directories or file extensions that make sense for you.

@metaskills
Copy link
Author

Just added xargs sed -i -E '$a\' to the end to make sure there is a new line at the end of the file too.

@ccmcbeck
Copy link

sweet. to enable this on Textmate 2, go here:

https://github.com/bomberstudios/Strip-Whitespace-On-Save.tmbundle

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