switching between extensions hpp cpp

I switch between hpp and cpp files all the time so having a quick way to do that is important to me.

  
" Function to switch to .hpp or .cpp
function! SwitchExtension(newext)
  let l:filename = expand("%:r") . "." . a:newext
  execute "edit " . l:filename
endfunction

" Leader mappings
nnoremap hh :call SwitchExtension("hpp")
nnoremap cc :call SwitchExtension("cpp")
  

edit this page