Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a pdf file from Vim using the default pdf application?

Tags:

vim

pdf

I want to open pdf files using their file links from Vim in the default pdf viewer application which is Preview on my osx.

There is gf normal command to open a file link inside Vim. But pdf files should be opened in an external application.

like image 962
Mert Nuhoglu Avatar asked Oct 27 '15 19:10

Mert Nuhoglu


People also ask

How do I change the default program for opening PDF files?

Right-click the PDF, choose Open With > Choose default program or another app in. 2. Choose Adobe Acrobat Reader DC or Adobe Acrobat DC in the list of programs, and then do one of the following: (Windows 10) Select Always use this app to open .

Can you open PDF with vim?

This tip shows how to use Vim to view the text in a PDF document. That can be useful to use Vim to see the differences between the text in two versions of a pdf. You need to install xpdf (available on all major platforms) as it provides the pdftotext utility to read the text from a pdf file.

What is the default PDF viewer in Ubuntu?

Evince is the default document viewer for PDF (Portable Document Format) and PostScript files but can also display other formats, such as images. It is designed to make reading documents a simple and hassle-free experience, and has intuitive previewing, indexing and searching capabilities.


1 Answers

As said by @Ken in the comments, you should use gx:

Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are
best seen with a special handler (ie. a tool provided with your computer).
Netrw allows one to invoke such special handlers by:

    * when Exploring, hit the "x" key
    * when editing, hit gx with the cursor atop the special filename

More information can be found in :help gx.

like image 92
rgoliveira Avatar answered Nov 10 '22 00:11

rgoliveira