Add auto-remove-whitespace

git-svn-id: http://photonzero.com/dotfiles/trunk@103 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
michener 2011-08-26 21:55:26 +00:00
parent a9e9e6d6ba
commit 18fd920110
2 changed files with 27 additions and 1 deletions

View file

@ -2,6 +2,7 @@
if exists("did\_load\_filetypes")
finish
endif
let b:auto_trim_whitespace=0
" Filetype mappingss
augroup markdown
au! BufRead,BufNewFile *.mkd setfiletype mkd
@ -18,6 +19,7 @@ augroup END
augroup java
autocmd BufRead *.java set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
autocmd BufRead *.java set makeprg=ant\ -find\ build.xml
autocmd FileType java let b:auto_trim_whitespace=1
augroup END
au BufNewFile,BufRead motd.public,/tmp/motd.public.r.* setf motd
@ -26,6 +28,7 @@ au Filetype html,xml,xsl source ~/.vim/closetag.vim
au BufRead,BufNewFile *.go set filetype=go
"Settings per filetype
augroup python
"autocmd FileType python set omnifunc=pythoncomplete#Complete
@ -36,13 +39,14 @@ augroup python
autocmd FileType python set shiftwidth=4
autocmd FileType python set expandtab
autocmd FileType python set nosmartindent
autocmd FileType python let b:auto_trim_whitespace=1
augroup END
augroup javascript
autocmd FileType javascript set ts=4
autocmd FileType javascript set softtabstop=4
autocmd FileType javascript set shiftwidth=4
autocmd FileType javascript set expandtab
autocmd FileType javascript let b:auto_trim_whitespace=1
augroup END
augroup mkd
@ -54,3 +58,7 @@ augroup mediawiki
autocmd BufRead,BufNewFile *.wikipedia.org* setfiletype mediawiki
augroup END
autocmd FileType go let b:auto_trim_whitespace=1
autocmd FileType cpp let b:auto_trim_whitespace=1
autocmd FileType perl let b:auto_trim_whitespace=1
autocmd FileType borg let b:auto_trim_whitespace=1

18
.vimrc
View file

@ -258,6 +258,15 @@ if g:google != 0
augroup filetypedetect
au WinEnter,BufNewFile,BufRead * call HighlightTooLongLines()
augroup END
if filereadable("/home/williasr/.vim.d/blaze.vim")
source /home/williasr/.vim.d/blaze.vim
" Load Blaze errors into quickfix mode
nmap <Leader>bl :call LoadBlazeErrors():cc
" Run the most appropriate blaze command on the target for the current file.
nmap <Leader>bb :call BlazeDwim()
" Run update_deps on the target for the current file.
nmap <Leader>bu :call UpdateDepsDwim()
endif
endif
if filereadable("/home/build/nonconf/google3/tools/tags/gtags.vim")
@ -316,3 +325,12 @@ function! AutoHighlightToggle()
endif
endfunction
" Removes trailing spaces
function AutoTrimWhitespace()
if b:auto_trim_whitespace == 1
%s/\s\+$//e
''
endif
endfunction
autocmd BufWritePre * :call AutoTrimWhitespace()