Created
February 1, 2013 15:55
-
-
Save invalidusrname/4692163 to your computer and use it in GitHub Desktop.
Trims whitespace in vim for ruby and puppet files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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