Skip to content

Instantly share code, notes, and snippets.

@wilson
Forked from defunkt/carbon.md
Created November 5, 2009 21:23
Show Gist options
  • Save wilson/227416 to your computer and use it in GitHub Desktop.
Save wilson/227416 to your computer and use it in GitHub Desktop.
use ruby instead of perl

Vim

autocmd BufWritePre * :%s/\s\+$//e

Emacs

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Textmate

http://blogobaggins.com/2009/03/31/waging-war-on-whitespace.html

In your existing codebase

find . -name '*.rb' | xargs ruby -pi -e 'sub!(/\s+$/, "\n")'

Rake task for a Rails app

desc "Remove unnecessary whitespace" task :whitespace do sh %Q{find app lib spec -name '.rb' -or -name '.haml' | xargs ruby -pi -e 'sub!(/\s+$/,"\n")'} end

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