保存時にtabを2space、行末空白削除
むかしのファイルとかいじるときにタブが混じってるとむ〜んという気分になるけどいちいち直すのめんどくさいからvimrcに保存時にtabを2スペースに変換するの記述した。
ついでに行末空白削除のも入れた。
" 保存時に行末の空白を除去する
" 保存時にtabを2スペースに変換する
function! s:remove_dust()
let cursor = getpos(".")
%s/\s\+$//ge
%s/\t/ /ge
call setpos(".", cursor)
unlet cursor
endfunction
autocmd BufWritePre * call <SID>remove_dust()