diff vim/vimrc @ 160:5997455e475b

Whitespace cleaning.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 03 Jan 2014 19:34:30 -0800
parents 7fd22eb11789
children 254c4f068808
line wrap: on
line diff
--- a/vim/vimrc	Mon Dec 16 16:40:42 2013 -0800
+++ b/vim/vimrc	Fri Jan 03 19:34:30 2014 -0800
@@ -259,6 +259,12 @@
 
     augroup END
 
+    augroup VimRCTrailingWhitespaces
+        au!
+
+        autocmd FileType c,cpp,java,php,ruby,python,js,css,less autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
+    augroup END       
+
 endif
 
 " }}}
@@ -411,6 +417,14 @@
     endif
 endfunction
 
+function! s:StripTrailingWhitespaces() abort
+    let l = line(".")
+    let c = col(".")
+    %s/\s\+$//e
+    let @/=''
+    call cursor(l, c)
+endfunction
+
 " }}}
 
 " Temporary stuff {{{