Skip to content

Instantly share code, notes, and snippets.

@invalidusrname
Created February 1, 2013 15:55
Show Gist options
  • Save invalidusrname/4692163 to your computer and use it in GitHub Desktop.
Save invalidusrname/4692163 to your computer and use it in GitHub Desktop.
Trims whitespace in vim for ruby and puppet files
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
" allow whitespace trimming for ruby and puppet files
autocmd BufWritePre *.rb :call TrimWhiteSpace()
autocmd BufWritePre *.pp :call TrimWhiteSpace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment