Skip to content

Commit

Permalink
Fixed #263
Browse files Browse the repository at this point in the history
  • Loading branch information
amix committed Apr 1, 2017
1 parent bbd0e81 commit 04ce579
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions vimrcs/basic.vim
Expand Up @@ -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


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Expand Down

0 comments on commit 04ce579

Please sign in to comment.