Last active
October 22, 2019 17:17
-
-
Save seanpianka/4811d02671a55bf8aeedd76e4a46e1a4 to your computer and use it in GitHub Desktop.
vim: delete all trailing whitespace from files matching certain patterns using vimscript
This file contains 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
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
for suffix in ["py", "js", "css", "cpp", "c", "h", "hpp", "rs", "groovy", "groovy.j2"] | |
execute 'autocmd BufWrite *.'.suffix.' :call DeleteTrailingWS()' | |
endfor | |
for prefix in ["Jenkinsfile"] | |
execute 'autocmd BufWrite '.prefix.'* :call DeleteTrailingWS()' | |
endfor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment