7

There are several features of TeXworks that I find substantially decrease my editing time. I tend to write a large number of rather small LaTeX files, which means I'm opening and closing files frequently. The fact that TeXworks automatically opens a pdf if available, and automatically tiles the editing and previewing windows for me saves a lot of time!

However, TeXworks, as a text editor, simply isn't as powerful as Vim (I much prefer the console version over Gvim). I would like to have the editing power of Vim, while retaining the windowing features of TeXworks. Is there any way to do this? Perhaps a set of Vim scripts that someone has written? Or is there a Vim plugin for TeXworks?

[EDIT] I can see from some comments that some folks are assuming I'm running Linux. While I am hoping to acquire a Linux laptop soon, right now I am running Windows XP. So terminal options are considerably more limited.

  • 2
    I'm not sure this helps, but have you had a look at Sublime Text? There is a LaTeX plugin for that and it also has a so-called 'vintage' mode to emulate the functionality of Vim, but at the same time keeping all the features that make Sublime Text stand out, windowing included. – Count Zero May 29 '13 at 22:03
  • 3
    Sounds to me like one solution would be to use a smarter window manager. So-called dynamic window managers tile active windows based on user-set layouts. 3 of the most popular are dwm, xmonad, and awesome. (See also a comparison of X window managers.) Each one requires a bit of work to set up, but you can key it to your exact preferred workflow. – jon May 29 '13 at 22:28
  • You can always dual boot if you want to play around with linux. After I used linux for a week, I totally deleted Windows and haven't looked back. – dustin May 30 '13 at 3:06
  • 2
    I am not an admin on my machine, and I'm not sure my sysadmin would like dual booting. I could always ask, I suppose. I do like Linux very much. – Adrian Keister May 30 '13 at 3:18
  • Or ask if your sysadmin would let you boot a live Linux distro? – cfr Jun 11 '14 at 1:25
3

I think the short answer is no but maybe someone has a set up for this.

What you are asking for is a GUI which isn't a GUI so I don't think that is possible. I have used both Vim and Emacs (Emacs now currently) and do all my editing in the terminal.

Here is my set up which may add what you need:

I use a slightly see through terminal that drops down from the top with the pdf underneath it. This way I can see through it or just hit F12 and it auto hides until I want it back. Then if I want to update the pdf, I just compile the file again and the updates appear on the pdf immediately. If you use synctex, you can then click on the pdf and have it jump to that spot in your terminal window for correcting or editing. In my view, this is the best you may get since you aren't using the GUI.

  • Can you get Vim automatically to open a corresponding pdf or dvi file? – Adrian Keister May 29 '13 at 16:31
  • 1
    @AdrianKeister you can set up in you .vimrc file that a pdf opens when you compile. – dustin May 29 '13 at 16:33
  • How about setting it up so that the pdf only opens with an error-free compile? – Adrian Keister May 29 '13 at 16:36
  • @AdrianKeister if there are serious errors, the pdf will be blank. If it is a forgotten paren or curly braces, I think it will still open. You can always right a python script to fit your needs and implement it with the vimrc. – dustin May 29 '13 at 16:39
  • Sounds good. Can I do this in Windows? Getting a terminal transparent is pretty straight-forward in Linux, I know. Could you please point me to the necessary .vimrc commands for opening the pdf's? – Adrian Keister May 29 '13 at 16:45
4

Disclaimer I use nvi not VIM! It is trivial to force VIM to open appropriate PDF file. Put something like this in your .exrc file (or whatever VIM configuration file is .vimrc)

map ^X :w^M:!make dvi-view

That would allow you to use key binding Ctrl+X to tex your file and automatically open dvi viewer with the dvi file after tex-ing. Note I am using in this example Xdvi because I know for the fact that direct and inverse search work with Xdvi. I do not use direct and inverse search since nvi doesn't have server mode so when you do inverse search Xdvi opens new instance of nvi with the file you are editing. However VIM supports server mode and inverse search works fine. You will also need to edit your Makefile as

FILE = filename

LATEX = latex
XDVI = xdvi
DVI = ${FILE}.dvi

dvi : 
        ${LATEX} ${FILE}.tex
        ${LATEX} ${FILE}.tex
dvi-view : dvi
        ${XDVI} ${DVI}

Granted you have srctex loaded into the document you are editing you will be able to tex your file, open Xdvi automatically and have direct and inverse search. Now toggling VIM instance and Xdvi is also trivial but the solution depends on your Window manager. I could tell you how to do in my window manager of choice (Calm Window Manager on OpenBSD) but that one only available as an unofficial port on FreeBSD (note CWM of OpenBSD is not really portable and meant to be used outside of OpenBSD).

To make TeXworks acting as a VIM is asking to have the vi keybindings at very least. I am not sure if TeXworks has those but they can definitely be hard coded. Now that is not a five minute job.

2

I use Vim-Latex suite on window and Sumatra pdf viewer that doesn't lock files so I can compile with \ll and open pdf with \lv.

  • 1
    More or less no PDF viewer with exception of Acroread locks file on Unix so that is not really here concern. However, historically inverse and direct search were possible on dvi files before pdf files that is way I used Xdvi in my example. – Predrag Punosevac May 30 '13 at 2:23
  • Except the OP is using Windows... – cfr Jun 11 '14 at 1:28
2

Another alternative is simply to use LaTeXTools of SublimeText. https://github.com/SublimeText/LaTeXTools It is a largely configurable plugin which provides the power of an GUI IDE but also takes advantage of built-in SublimeText editing features such as a quite functional vim plugin.

1

I just discovered writeLaTeX. It's a cloud service with real-time compilation, pretty much any package installed that I'd want, and you can set the editor to vim mode. It has the source file on the left, and the output on the right just like TeXworks. This is a partial answer, at least. You can upload your own style files. It's a very intriguing concept that I might well encourage my students to use, as it obviates the need to install software.

  • 1
    The owner of either write or share LaTeX is on this site. He/she may know about this type of set up better. So I found him. It is writeLaTeX: jdleesmiller – dustin Aug 21 '13 at 3:04
  • 3
    You may find that vim mode isn't sufficiently vim-like for your taste. Or not. I've always found vi-modes in other editors annoying, although I did use Emacs's vi mode for a while. – Mars Aug 21 '13 at 4:47
  • 1
    Kile also has a vim mode. I like vim but I can't stand using Kil's vim mode. (Not even when I keep writing :w to try to save my file!) – cfr Jun 11 '14 at 1:29
0

This may not be what you want, and it may seem crude, but it works well and I've been using it for a long time.

I use vim, skim, and make. I keep vim open in one window, skim, in another, and have a shell window with a loop that runs make. This needs to be visible because it's where the LaTeX errors will show up.

Skim is a free PDF reader that has a setting that will make it check to see if the original PDF file has changed. Not sure whether it runs in OSes other than OS X.

A Makefile is a script for make that tells make to do something to file X if files Y, X, etc. have changed.

I configure a Makefile to run xelatex on a .tex file that I'm editing whenever it changes. This creates a new PDF. Then skim loads the new version of the PDF.

Then I start a shell script that runs make in a loop.

If you're using a DVI previewer, try to find one that will watch the dvi file for changes. Alternatively, some dvi previewers can be told to reload the file. In the old days, I had the Makefile run a command that sent a Unix signal to the dvi previewer, telling it to reload the file. There used to be a way to do something similar to Acrobat Reader, but it didn't work very well. That's why I switched to Skim (which is not perfect).

Here's a bare bones Makefile:

myfile.pdf: myfile.tex myfile.bbl
    xelatex myfile.tex

You would put text something like that in a file named "Makefile", and put in the same directory as your .tex files.

For OS X/Unix/Linux, you can write a loop like this:

#!/bin/bash
while true; do sleep 2; make -s "$@"; done

You would put this in a text file and make it executable. Then run this script from the directory where the Makefile is. You can do something similar in Windows, but the shell language is different. If there's no make installed in Windows, there are free Windows versions available. Linux will have it preinstalled.

0

I found the cleanest solution being to add a Makefile; following this answer, but with this added to clean:

rm -f *.aux *.bbl *.blg *.log *.out *.toc *.synctex.gz *.fls *.fdb_latexmk *.swp

Then rather than using @Mars option of sleep 2—run every 2 seconds—use:

while inotifywait -e close_write *.tex; do make; done

You can set this as a new make task, e.g.: make always, always: while inotifywait

NOTE: This is for Linux. If you want task automation for all platforms, using something like watchdog.


Now no matter what editor you use, new PDFs will be compiled whenever you close_write (save) any *.tex file in cwd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.