[Tex/LaTex] Best (neo)vim setup for managing multiple Latex projects

pdftexvim

I am in the process of switching from Sublime to neoVIM+vimtex for writing (pdf)latex documents.

In Sublime I have currently simply added each folder with a Latex document with "Add folder to project…". This way all folders/documents are all nicely shown under each other in the sidebar on the left and I can "switch" between them by simply opening a file in the right folder.

What is the recommended way of efficiently handling multiple separate "latex projects" with multiple source files etc. each in vim? I've found the vim-ctrlspace plugin which seems to do something similar but, despite trying for some time, wasn't able to set it up properly for my needs.

Any other recommendations/best practices/etc?

Thank you very much!

Best Answer

I am rather fond of the UNIX creed of "Have each tool do one job, and do it well." (or similar). So the thing for which I use Vim, primarily, is editing text. Project management and such I do via the terminal, for the most part. Still, for those occasions when I do want to move around the file system from within Vim, I use easytree these days.

Besides that, these are the plugins which I use to make my TeX life easier (they're not strictly TeX-related though, except for one):

  • bufexplorer,
  • youcompleteme and related to that:
  • youcompleteme-latex-semantic-completer.

All plugins (there are more besides these, for other things) are managed by Vundle, except for the two youcompleteme ones; I install those from my Linux repos because I have found them to be a bit of a pain to compile and get to run from scratch. But when ycm works, I really like it.

One feature which I have recently started to use rather heavily for TeX activities are (manual) folds. I have found them to be very handy indeed. For example, a 1700-line class file on which I'm working becomes quite handy by using folds. The occasions when I get lost somewhere in the bowels of a lengthy file have become drastically less frequent.

This is gvim, (using the corporation color scheme, in case anyone is wondering) and those nice folds (the terminal version of vim does not support the colors needed for this, so I've started using gvim instead):

gvim setup (Note: The last line is for setting up the folds.)

All in all, what I think is far more important than getting the "ultimate, be-all-end-all" plugin combo, is to make sure that you know your setup (e.g. key combinations), and have it configured so that it suits your work flow. This depends heavily on personal preferences. What works for me might not work at all for you, and vice versa. This is also the primary reason I completely scrapped my .vimrc last fall and re-wrote it from scratch, as a side note.

For example, the bufexplorer plugin is primarily very useful to me because I have it mapped to a good key combination, not because it's the best plugin ever for navigating buffers (though I do like it).

Also, I tend to have a (simple, most of the time) Makefile in each TeX project directory, and have it set up so that I can call it from within Vim and compile the default target (via the LEADER key; very quick). Having the pdf open in a window right next to my editor then basically gives me an IDE-like setup, without the overhead of actually running an IDE, and the niceties of having vim and Makefiles. Again, one tool for each job and all that.

I suppose the point of my long ramble is: Don't overdo it with the plugins; my recommended solution for your specific question would be the terminal and easytree for navigating from within Vim. But your mileage may vary, and just because this has worked for me does not mean it will for you, fair enough. But perhaps there is a modicum of useful information somewhere in here for somebody. ;-)

As an addendum on the topic of terminals: I use ZSH, and I have found the autojump plugin absolutely indispensible. It allows for very quick and convenient file system navigation. Also, tmux. Very practical; couldn't live without it. Well, could, but really don't want to.

EDIT: Since I mentioned it: My .vimrc, in case anyone might find it useful: https://github.com/alpenwasser/dotfiles/blob/master/vimrc

Related Question