Alex
Alex

Reputation: 15333

Is it possible to have Vim open a file in its default (non-vim) editor?

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?

Upvotes: 1

Views: 118

Answers (2)

Geoff Reedy
Geoff Reedy

Reputation: 36011

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>"))

Upvotes: 1

Seth Johnson
Seth Johnson

Reputation: 15172

If you're using a mac, you can use the open command.

Upvotes: 0

Related Questions