Vim Tips Wiki

Open PDF files

1,610pages on
this wiki
Revision as of 06:22, July 13, 2012 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Tip 1356 Printable Monobook Previous Next

created 2006 · complexity basic · version 7.0

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.


Put one of the following mappings in your vimrc:

:command! -complete=file -nargs=1 Rpdf :r !pdftotext -nopgbrk <q-args> -
:command! -complete=file -nargs=1 Rpdf :r !pdftotext -nopgbrk <q-args> - |fmt -csw78

These define the :Rpdf command to read the result of converting a pdf document to text. The text is read into the current buffer after the current line. The first reads the pdf with each paragraph as a long line, while the second wraps long lines (if the fmt utility is available).

For example, the following commands open a new tab page and read the text from a pdf document into the buffer.

:Rpdf example.pdf

See alsoEdit


Advertisement | Your ad here

Around Wikia's network

Random Wiki