Skip to content

Instantly share code, notes, and snippets.

@nordringrayhide
Forked from wilson/carbon.md
Created October 7, 2011 04:38
Show Gist options
  • Save nordringrayhide/1269451 to your computer and use it in GitHub Desktop.
Save nordringrayhide/1269451 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