Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
amix committed Apr 1, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent bbd0e81 commit 04ce579
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions vimrcs/basic.vim
Original file line number Diff line number Diff line change
@@ -299,14 +299,18 @@ if has("mac") || has("macunix")
vmap <D-k> <M-k>
endif

" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
" Delete trailing white space on save, useful for some filetypes ;)
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun

if has("autocmd")
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

0 comments on commit 04ce579

Please sign in to comment.