Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open file externally from gvim

Tags:

file

vim

ubuntu

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.

like image 959
andreas-h Avatar asked Sep 10 '25 23:09

andreas-h


1 Answers

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

like image 149
sappjw Avatar answered Sep 13 '25 18:09

sappjw