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.
Put an &
at the end of the command. I learned this from how LaTeX-Box does it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With