andreas-h
andreas-h

Reputation: 11110

Open file externally from gvim

In vim on the console, I can move the cursor on the name of a file which lies in the same directory as the currently open file, and issue the command !xdg-open %:p:h/<cfile>. This will open the file in an external viewer, as defined by the OS. This is great, but on my system, it doesn't seem to work when using gvim.

This is the command I put into my ~/.vimrc file:

nnoremap <leader>o :silent !xdg-open %:p:h/<cfile><CR>

What do I have to do so that this works both in vim on the console and in gvim?

I'm running Ubuntu Linux 12.04LTS.

Upvotes: 3

Views: 435

Answers (3)

sappjw
sappjw

Reputation: 499

Put an & at the end of the command. I learned this from how LaTeX-Box does it.

Upvotes: 3

andreas-h
andreas-h

Reputation: 11110

Following this post here: https://superuser.com/a/407675/104415, putting a & at the end of the command makes it work in both gvim and vim:

nnoremap <leader>o :silent !xdg-open %:p:h/<cfile>&<CR>

Upvotes: 1

SaltyEgg
SaltyEgg

Reputation: 1558

Maybe you could try

:set debug=msg

and then see whether there are any errors?

Upvotes: 0

Related Questions