]> git.rmz.io Git - dotfiles.git/blobdiff - vim/ftplugin/cpp.vim
vim: update fswitch for cpp
[dotfiles.git] / vim / ftplugin / cpp.vim
index be1b64d268ce04f2e39a1bf5511204616dc74170..fabf6b9a541a3679b753d3dd34b8e3cd1954b39d 100644 (file)
@@ -15,12 +15,21 @@ setlocal cinoptions+=:0  " don't indent case labels
 let b:load_doxygen_syntax = 1
 
 augroup fswitch
 let b:load_doxygen_syntax = 1
 
 augroup fswitch
-    au BufEnter *.h   let b:fswitchdst  = 'cpp,c'
-    au BufEnter *.h   let b:fswitchlocs = 'reg:|include.*|source|'
-    au BufEnter *.cpp let b:fswitchdst  = 'h'
-    au BufEnter *.cpp let b:fswitchlocs = 'reg:|source|include/**|'
+    au BufEnter *.hpp let b:fswitchdst  = 'cpp,c'
+    au BufEnter *.hpp let b:fswitchlocs = 'reg:|include.*|src|'
+    au BufEnter *.cpp let b:fswitchdst  = 'hpp,h'
+    au BufEnter *.cpp let b:fswitchlocs = 'reg:|src|include/**|'
 augroup END
 
 augroup END
 
+let g:switch_const_definitions =
+    \ [ {
+    \   '\%(const \)\@!\([[:alnum:]_:<>]\{-}\) \%(&\)\@!': 'const \1 ',
+    \   'const \([[:alnum:]_:<>]\{-}\) &\@!': 'const \1 &' ,
+    \   'const \([[:alnum:]_:<>]\{-}\) &': '\1 '
+    \ } ]
+
+nnoremap <buffer> <leader>c :call switch#Switch(g:switch_const_definitions, {})<cr>
+
 nnoremap <buffer> gd :YcmCompleter GoTo<CR>
 nnoremap <buffer> <C-W>d :vs<CR>:YcmCompleter GoTo<CR>
 
 nnoremap <buffer> gd :YcmCompleter GoTo<CR>
 nnoremap <buffer> <C-W>d :vs<CR>:YcmCompleter GoTo<CR>