X-Git-Url: http://www.git.stargrave.org/?p=dotfiles.git;a=blobdiff_plain;f=vim%2F.vim%2Fftplugin%2Fc%2Falt.vim;fp=vim%2F.vim%2Fftplugin%2Fc%2Falt.vim;h=35ef67b9bd8f29ed3c040b12444b2cff5dfbff1c;hp=609f37df4ea551c0e21c7c86c29996b217087377;hb=e40e7338c2e589d1ca6cf37fdaa5c98035f281dd;hpb=8bb7ea5b4a46ff5ae1fe31233944ada15bc446d0 diff --git a/vim/.vim/ftplugin/c/alt.vim b/vim/.vim/ftplugin/c/alt.vim index 609f37d..35ef67b 100644 --- a/vim/.vim/ftplugin/c/alt.vim +++ b/vim/.vim/ftplugin/c/alt.vim @@ -1 +1,21 @@ -nnoremap :execute "edit %<." . {"c": "h", "h": "c", "cc": "hh", "hh": "cc"}[expand("%:e")] +if exists("*CAltSwitcher") | finish | endif + +let g:AltExts = { + \ "c": ["h"], + \ "h": ["c", "cc"], + \ "cc": ["hh", "h"], + \ "hh": ["cc"] +\} + +function! CAltSwitcher() abort + for ext in g:AltExts[expand("%:e")] + let name = expand("%<") . "." . ext + if filereadable(name) + execute "edit " . name + return + endif + endfor + echomsg "no alt found" +endfunction + +nnoremap :call CAltSwitcher()