Skip to content

Instantly share code, notes, and snippets.

@LeventErkok
Created March 22, 2012 07:33
Show Gist options
  • Save LeventErkok/2156865 to your computer and use it in GitHub Desktop.
Save LeventErkok/2156865 to your computer and use it in GitHub Desktop.
Jump to an imported file
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