]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/ftplugin/c/alt.vim
pv utility wrapper
[dotfiles.git] / vim / .vim / ftplugin / c / alt.vim
1 if exists("*<SID>CAltSwitcher") | finish | endif
2
3 let g:AltExts = {
4     \ "c": ["h"],
5     \ "h": ["c", "cc"],
6     \ "cc": ["hh", "h"],
7     \ "hh": ["cc"]
8 \}
9
10 function! <SID>CAltSwitcher() abort
11     for ext in g:AltExts[expand("%:e")]
12         let name = expand("%<") . "." . ext
13         if filereadable(name)
14             execute "edit " . name
15             return
16         endif
17     endfor
18     echomsg "no alt found"
19 endfunction
20
21 nnoremap <buffer> <C-^> :call <SID>CAltSwitcher()<CR>