Created
February 22, 2011 01:53
-
-
Save Raimondi/838089 to your computer and use it in GitHub Desktop.
Better gf
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
" Always edit a file on gf, but be nice and ask | |
map gf :<C-U>call GoFile()<CR> | |
function! GoFile() | |
try | |
normal! gf | |
catch /^Vim\%((\a\+)\)\=:E447/ | |
let q = substitute(v:exception,'^Vim\%((\a\+)\)\=:E\d\+: \(.*\)','\1','') . ', would you like to create it?' | |
try | |
buffer <cfile> | |
catch /^Vim\%((\a\+)\)\=:E94/ | |
if confirm(q ,"&Yes\n&No\n&Cancel",3) == 1 | |
exec 'edit '.expand('%:p:h').'/'.expand('<cfile>') | |
endif | |
endtry | |
endtry | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment