Skip to content

Instantly share code, notes, and snippets.

@ironhouzi
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ironhouzi/c21b8ed2b656baaa0c6a to your computer and use it in GitHub Desktop.
Save ironhouzi/c21b8ed2b656baaa0c6a to your computer and use it in GitHub Desktop.
Toggle between c/h-files
function! ToggleCH()
let extension = expand('%:e')
if extension =~ 'c'
let extension = '.h'
elseif extension =~ 'h'
let extension = '.c'
else
return
endif
let filename = expand('%:r') . extension
if filereadable(filename)
execute "e " . filename
endif
endfunction
command! -register ToggleCH call ToggleCH()
nnoremap <silent> <leader>h :<C-u>ToggleCH<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment