]> git.rmz.io Git - dotfiles.git/commitdiff
vim: add constness switcher for cpp files
authorSamir Benmendil <me@rmz.io>
Sat, 1 Apr 2017 17:35:38 +0000 (18:35 +0100)
committerSamir Benmendil <me@rmz.io>
Sat, 1 Apr 2017 17:35:38 +0000 (18:35 +0100)
vim/ftplugin/cpp.vim

index be1b64d268ce04f2e39a1bf5511204616dc74170..23503b8ef1b861a28b36653459fd5d2b15df485f 100644 (file)
@@ -21,6 +21,15 @@ augroup fswitch
     au BufEnter *.cpp let b:fswitchlocs = 'reg:|source|include/**|'
 augroup END
 
     au BufEnter *.cpp let b:fswitchlocs = 'reg:|source|include/**|'
 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>