VIM:是否可以在拆分窗口中查看pdf文件? [英] VIM: Is it possible to view pdf file in a split window?

查看:512
本文介绍了VIM:是否可以在拆分窗口中查看pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用gVim在拆分窗口中查看pdf文件,有人知道这是否可行吗?怎么样?

I would like to view a pdf file in a split window using gVim, does anyone know if this is possible? How?

一些细节:我最近刚开始使用vim,并在阅读pdf时使用它做笔记.我写自己的笔记,但是很多时候我会从pdf复制文本,因此流畅的复制会很好.目前,我需要使用alt + tab进行pdf查看器,转到鼠标或箭头键,选择文本,进行复制,将alt + tab返回vim.当然,这不是一项艰巨的任务,但是使用vim,我感觉没有鼠标,将手放在主行"并且不需要外部程序alt + tab即可实现.

Some details: I just recently started using vim and use it to make notes, while reading a pdf. I write own notes, but quite often I copy text from pdf, so smooth copying would be nice. Currently I need to alt+tab for pdf viewer, go to mouse or arrow keys, select text, copy, alt+tab back to vim. Of course this is not a huge task, but using vim I feel it could be possible without mouse, keeping hands at "home row", and not needing external program alt+tab to...

理想情况下,我希望pdf能够按预期显示.如果不可能,我将尝试使用某些插件将pdf显示为文本表示形式.

Ideally I would like pdf to be shown as it is supposed to be. If that is not possible, I will try how pdf shows as text representation using some plugin.

推荐答案

Vim是文本编辑器,因此只能编辑文本.因此,可以,您可以在二进制级别上编辑PDF,但是不能,您不能查看PDF的内容,因为它们本来就是要显示的.您可以使用xpdf包先将PDF转换为文本,然后再查看,但效果并不理想.但是,有一些有用的自动命令可以让您在vim中打开"非文本文件时使用其默认程序来打开它们.我用这些:

Vim is a text editor, so it only edits text. So, yes you can edit the PDF on a binary level, but no you can't view the contents of the PDF as they are meant to be displayed. You can use the xpdf package to convert the PDF to text first and then view that, but the results aren't perfect. However, there are some useful autocommands to allow you to open non-text files with their default program when you "open" them in vim. I use these:

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

如果使用的是Linux发行版,则可以使用!xdg-open代替!open. any2pdf命令中有一个我使用的脚本可在打开文件之前将这些文件转换为PDF.如果您只想使用其默认程序打开所有内容,则可以对其进行编辑.例如,

Instead of !open you can use !xdg-open if you're using a Linux distro. The any2pdf command there is a script I use that converts those files to a PDF before opening them. You can edit this if you just want to open everything with its default program. For example,

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

您可能还想研究诸如 dwm

You might also want to look into window managers like dwm or ratpoison, which come pretty close to what you're asking for.

这篇关于VIM:是否可以在拆分窗口中查看pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆