Last active
August 29, 2015 14:20
-
-
Save ironhouzi/c21b8ed2b656baaa0c6a to your computer and use it in GitHub Desktop.
Toggle between c/h-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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