07/02/04 23:57:23
C言語のファイルを開いたときに適切なインデント設定をするスクリプト
単純だけどけっこう楽になった
いろんな言語を認識できるようにしたら便利だろうなぁ
だれかやってくんないかなぁ…
autocmd FileType c,cpp call s:SetIndent()
function! s:SetIndent()
let pos = getpos('.')
if search('{$') != 0 && search('^\s\+\S', 'W') != 0
let &l:shiftwidth = indent(line('.'))
let &l:softtabstop = indent(line('.'))
let &l:expandtab = (search('^\t') == 0)
endif
call setpos('.', pos)
endfunction