Is it possible to have Vim open a file in its default (non-vim) editor?
Question
I have cTags set up to tag a bunch of custom stuff for simple internal scripting language I use at work. For various reasons, I'd like to have it set up so that if I <C-]>
on certain tags vim opens them in their default editor rather than in another buffer. Is it possible to set this up?
Solution
The following function and autocommand will cause matching files to be loaded in the program associated with the file type, just like hitting x
from a vim dir explorer buffer.
function s:OSOpen(fname, bufname)
call netrw#NetrwBrowseX(a:fname,0)
exec "bdel " . a:bufname
endfunction
" replace the file pattern with whatever you need
au BufEnter *.txt call s:OSOpen(expand("<afile>"), expand("<abuf>"))
OTHER TIPS
If you're using a mac, you can use the open
command.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow