mirror of
https://github.com/amix/vimrc
synced 2024-12-12 13:12:32 +00:00
This commit is contained in:
parent
bbd0e816ca
commit
04ce579f61
1 changed files with 12 additions and 8 deletions
|
@ -299,14 +299,18 @@ if has("mac") || has("macunix")
|
||||||
vmap <D-k> <M-k>
|
vmap <D-k> <M-k>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
|
" Delete trailing white space on save, useful for some filetypes ;)
|
||||||
func! DeleteTrailingWS()
|
fun! CleanExtraSpaces()
|
||||||
exe "normal mz"
|
let save_cursor = getpos(".")
|
||||||
%s/\s\+$//ge
|
let old_query = getreg('/')
|
||||||
exe "normal `z"
|
silent! %s/\s\+$//e
|
||||||
endfunc
|
call setpos('.', save_cursor)
|
||||||
autocmd BufWrite *.py :call DeleteTrailingWS()
|
call setreg('/', old_query)
|
||||||
autocmd BufWrite *.coffee :call DeleteTrailingWS()
|
endfun
|
||||||
|
|
||||||
|
if has("autocmd")
|
||||||
|
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
Loading…
Reference in a new issue