Skip to content

Commit

Permalink
Merge pull request spf13#465 from johntyree/ws_strip
Browse files Browse the repository at this point in the history
Move test for whitespace stripping out of function.
  • Loading branch information
spf13 committed Oct 12, 2013
2 parents 28673c0 + b83a62f commit a89c00f
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
" Remove trailing whitespaces and ^M chars
autocmd FileType c,cpp,java,go,php,javascript,python,twig,xml,yml autocmd BufWritePre <buffer> call StripTrailingWhitespace()
" To disable the stripping of whitespace, add the following to your
" .vimrc.before.local file:
" let g:spf13_keep_trailing_whitespace = 1
autocmd FileType c,cpp,java,go,php,javascript,python,twig,xml,yml autocmd BufWritePre <buffer> if !exists('g:spf13_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
autocmd FileType go autocmd BufWritePre <buffer> Fmt
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell setlocal expandtab shiftwidth=2 softtabstop=2
Expand Down Expand Up @@ -890,20 +893,15 @@

" Strip whitespace {
function! StripTrailingWhitespace()
" To disable the stripping of whitespace, add the following to your
" .vimrc.before.local file:
" let g:spf13_keep_trailing_whitespace = 1
if !exists('g:spf13_keep_trailing_whitespace')
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
%s/\s\+$//e
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endif
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
%s/\s\+$//e
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" }

Expand Down

0 comments on commit a89c00f

Please sign in to comment.