Guest User

Untitled

a guest
Jul 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. " Always edit a file on gf, but be nice and ask
  2. map gf :<C-U>call GoFile()<CR>
  3.  
  4. function! GoFile()
  5. try
  6. normal! gf
  7. catch /^Vim\%((\a\+)\)\=:E447/
  8. let q = substitute(v:exception,'^Vim\%((\a\+)\)\=:E\d\+: \(.*\)','\1','') . ', would you like to create it?'
  9. try
  10. buffer <cfile>
  11. catch /^Vim\%((\a\+)\)\=:E94/
  12. if confirm(q ,"&Yes\n&No\n&Cancel",3) == 1
  13. exec 'edit '.expand('%:p:h').'/'.expand('<cfile>')
  14. endif
  15. endtry
  16. endtry
  17. endfunction
Add Comment
Please, Sign In to add comment