Created
March 22, 2012 07:33
-
-
Save LeventErkok/2156865 to your computer and use it in GitHub Desktop.
Jump to an imported file
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! OpenHaskellFile() | |
let f = tr(matchstr(getline(line('.')), '\(import\s*qualified\|import\)\s*\zs[A-Za-z0-9.]\+'), ".", "/") . ".hs" | |
if f == ".hs" | |
echohl ErrorMsg | |
echo "Not on a valid import line!" | |
echohl NONE | |
return | |
endif | |
if filereadable(f) | |
if (&modified) | |
echohl ErrorMsg | |
echo "Current buffer is modified, save it first!" | |
echohl NONE | |
else | |
execute ':e ' . f | |
endif | |
else | |
echohl ErrorMsg | |
echo "Can't find file \"" . f . "\" in path" | |
echohl NONE | |
endif | |
endfunction | |
:map <silent> ghf :call OpenHaskellFile()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment