Guest User

Untitled

a guest
Jun 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. " :WhichEdit {{{
  2. MyAlterCommand we WhichEdit
  3. command!
  4. \ -nargs=+
  5. \ WhichEdit
  6. \ call s:cmd_which_edit([<f-args>])
  7.  
  8. function! s:system(command, args) "{{{
  9. " For shellescape(), set noshellslash
  10. let save_shellslash = &shellslash
  11. set noshellslash
  12. try
  13. return system(
  14. \ join([a:command] + map(copy(a:args), 'shellescape(v:val)'), ' ')
  15. \)
  16. finally
  17. let &shellslash = save_shellslash
  18. endtry
  19. endfunction "}}}
  20. function! s:cmd_which_edit(args) "{{{
  21. let [exe; args] = a:args
  22. try
  23. let out_path = s:system(exe, args)
  24. let out_path = substitute(out_path, '\n$', '', '') " chomp
  25. if filereadable(out_path)
  26. execute 'edit' out_path
  27. endif
  28. catch
  29. echohl WarningMsg
  30. echomsg v:exception
  31. echohl None
  32. endtry
  33. endfunction "}}}
  34.  
  35. " }}}
Add Comment
Please, Sign In to add comment