Vimでは特定のファイルを開いた時にfiletype
が設定されます。
filetypeはset filetype?
で確認でき、
filetype毎の設定を以下のように設定できます。
autocmd FileType cpp {設定項目}
ただ、C++ファイルを開いた時の設定を全てautocmdでやると、
非常に長くなり読みづらいので以下のようにします。
augroup CppConfigurations
autocmd! CppConfigurations
autocmd FileType cpp call s:CppConfigurations()
augroup END
function! s:CppConfigurations()
{ここにC++ファイルを開いた時の設定を書きまくる}
endfunction
includeディレクトリをpathに設定する事で、
ヘッダファイルをgf
で開く事ができるようになります。
setlocal path=/usr/include,/usr/local/include
setlocal tabstop=4
setlocal shiftwidth=4
setlocal noexpandtab
<Space>ii
でinclude行の末尾にジャンプして、インサートモードに入ります。
nnoremap <buffer><silent> <Space>ii :execute "?".&include<CR> :noh<CR> o
BOOST_PP_*
のキーワードに対してハイライトを有効にします。
syntax match boost_pp /BOOST_PP_[A-z0-9_]*/
highlight link boost_pp cppStatement
NeoBundle 'tyru/caw.vim'
nmap \c <Plug>(caw:I:toggle)
vmap \c <Plug>(caw:I:toggle)
nmap \C <Plug>(caw:I:uncomment)
vmap \C <Plug>(caw:I:uncomment)
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Shougo/unite-outline'
nmap ,out :Unite outline -winheight=10<CR>
nmap ,inc :Unite file_include -winheight=10<CR>
setlocal matchpairs+=<:>