vim設定 拡張子でタブ幅を変更
#contents
拡張子で指定する
HOME/.vimrcを設定
".rhtml, .rbでタブ幅を2に変更 au BufNewFile,BufRead *.rhtml set nowrap tabstop=2 shiftwidth=2 au BufNewFile,BufRead *.rb set nowrap tabstop=2 shiftwidth=2
".c, .cpp, .hでタブ幅を4に変更 au BufNewFile,BufRead *.c set nowrap tabstop=4 shiftwidth=4 au BufNewFile,BufRead *.cpp set nowrap tabstop=4 shiftwidth=4 au BufNewFile,BufRead *.h set nowrap tabstop=4 shiftwidth=4
ファイルタイプを自動判別してインデントを指定する
if has("autocmd") " ファイルタイプ別インデント、プラグインを有効にする filetype plugin indent on " カーソル位置を記憶する autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif endif