Vim is a text editor, so it only edits text. So yes, you can edit the PDF at the binary level, but you cannot view the contents of the PDF in the way they should be displayed. You can use the xpdf package to convert PDF to text first and then view it, but the results are not perfect. However, there are some useful auto-commands that allow you to open non-text files with their default program when you "open" them in vim. I use them:
augroup nonvim au! au BufRead *.png,*.jpg,*.pdf,*.gif,*.xls* sil exe "!open " . shellescape(expand("%:p")) | bd | let &ft=&ft au BufRead *.ppt*,*.doc*,*.rtf let g:output_pdf = shellescape(expand("%:r") . ".pdf") au BufRead *.ppt*,*.doc*,*.rtf sil exe "!/usr/local/bin/any2pdf " . shellescape(expand("%:p")) au BufRead *.ppt*,*.doc*,*.rtf sil exe "!open " . g:output_pdf | bd | let &ft=&ft augroup end
Instead of !open you can use !xdg-open if you are using a Linux distribution. The any2pdf command is a script I use , which converts these files to PDF before opening them. You can edit this if you just want to open everything with the default program. For instance,
augroup nonvim au! au BufRead *.png,*.jpg,*.pdf,*.gif,*.xls*,*.ppt*,*.doc*,*.rtf sil exe "!open " . shellescape(expand("%:p")) | bd | let &ft=&ft augroup end
You can also look in window managers, such as dwm or ratpoison , that come close to what you ask.
source share