There's a very similar question on StackOverflow: https://stackoverflow.com/q/311118/695132
I'll copy my answer to that one here:
It's possible to make something like this yourself. Here's a description of the setup I use on Windows:
What you need:
- A text editor that can perform an action each time the document has changed
- A fast way to recompile LaTeX (e.g. precompile the preamble)
- A viewer that can quickly reload the document.
I used gVim as the text editor, latexdaemon as the compilation engine, and Sumatra as the PDF viewer.
In Vim, issue the command :au! CursorHoldI,CursorHold <buffer> silent! :update
to make it auto-save the document every time you stop typing. Also :set updatetime=800
to set the timeout after which saving happens to a low value.
latexdaemon will auto-compile the document in an efficient way every time it's changed. Use the following at the beginning of the file to make it produce PDF:
%Daemon> ini=pdflatex
Or just start it with latexdaemon -ini=pdflatex
.
Sumatra will automatically re-load the file every time it is changed, and it will not lock the PDF (so it can be recompiled without closing Sumatra first).
This recipe will give you an almost real-time preview, but it takes some effort to set up, and is not without issues. For example, you might not want to continuously auto-save, in case you'd want to revert to an earlier version.
There's a lot to improve on this, but I've been using it for some time (after reading your question), and thought putting the recipe out here might be useful for others too.
Since I was lazy, I just put everything to set this up into a .bat file:
@start C:\Path\To\Sumatra\SumatraPDF.exe %1.pdf
@start latexdaemon -ini=pdflatex %1.tex
@gvim -c ":au! CursorHoldI,CursorHold <buffer> silent! :update" -c ":set updatetime=800" %1.tex