Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen some videos on YuoTube where people are doing some cool things with Emacs, e.g. compiling a LaTeX file and viewing it as a pdf from within Emacs. I have also seen a graphviz DOT file compiled and it's PNG viewed within Emacs. Can similar things be done with gvim?

share|improve this question
up vote 2 down vote accepted

Does it really matter whether the preview is inside Vim or external to it?

Here's what I do. In my .vimrc, I have:

" save file whenever cursor moves
function! Update_if_possible()
    if filewritable(bufname("%"))
        update
    endif
endfunction
au CursorMoved * call Update_if_possible()
au CursorMovedI * call Update_if_possible()

This causes (g)vim to save the file whenever the cursor moves. In effect, the file is always saved this way.

I use the latex-box plugin for writing LaTeX, which uses latexmk to compile. Latexmk can be configured to auto-recompile whenever the file changes.

On the left side of my screen I put the gvim window. On the right side, I put a PDF viewer which auto-reloads whenever the PDF changes. (You can use any of several for linux: evince, okular, zathura, xpdf, etc.) The upshot is that the PDF previewer updates as I type. It's not nearly as fast as, say, gummi's live preview, but it's pretty close. It's certainly better than the emacs video you linked to, since unlike that, I don't even have to do anything to compile; gvim's constant saving of the file coupled with latexmk means the file is always compiling as I type, and hence, the PDF preview is always updating.

share|improve this answer

No. Within gvim you can compile a file and display the results with an external viewer in its own window, but not within a gvim window.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .