Skip to content

Instantly share code, notes, and snippets.

@jamal
Created January 24, 2015 14:36
Show Gist options
  • Save jamal/bdaccbb02e60a26d5464 to your computer and use it in GitHub Desktop.
Save jamal/bdaccbb02e60a26d5464 to your computer and use it in GitHub Desktop.
Simple Vimscript to switch between source and header files in C++ using ctags, requires --extra=+f to be passed to ctags
function! SwitchSourceHeader()
if (expand("%:e") == "cpp")
execute 'tag' join([expand("%:t:r"), "h"], ".")
else
execute 'tag' join([expand("%:t:r"), "cpp"], ".")
endif
endfunction
map <Leader>o :call SwitchSourceHeader()<CR>
map <Leader>i :vert belowright split<CR>:call SwitchSourceHeader()<CR> " Open alt file in a right pane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment