autocmd FileType python set tabstop 4 shiftwidth 4 expandtab ai
autocmd FileType ruby set tabstop 2 shiftwidth 2 softtabstop 2 expandtab ai
autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype markdown.mkd
autocmd BufNewFile *.sh,*.py exec :call AutoSetFileHead()
function! AutoSetFileHead()
.sh
if filetype sh
call setline(1, #!/bin/bash )
endif
python
if filetype python
call setline(1, #!/usr/bin/env python )
call append(1, # encoding: utf-8 )
endif
normal G
normal o
normal o
endfunc
autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre buffer :call SID StripTrailingWhitespaces()
fun! SID StripTrailingWhitespaces()
let l line( . )
let c col( . )
%s/s $//e
call cursor(l, c)
endfun