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!

  • 1
    I create folders and move/copy files in the shell, and just use Vim for editing. But you can open a whole folder of files in Vim (vim Documents/latexproject/); you can use buffers and multiple panes to, say, edit the main document and its class file in different panes. E.g., vim -O2 file.tex class.cls will open the two files in parallel panes. Or use the buffer and pane-splitting commands (:vs, :sp, :bn, :bp) once you're in vim. – musarithmia May 2 '17 at 19:39
  • 2
    Sessions are also a useful built-in tool. Check :help mksession. – marsupilam May 2 '17 at 20:22
  • 1
    To open multiple files in seperate tabs one might use vim -p *.tex in the shell. – Skillmon May 2 '17 at 20:58
  • 1
    Also there is the vim-extension NERD-tree. – Skillmon May 2 '17 at 21:00
  • 1
    If you use terminal Vim plus tmux, you have a low-budget IDE. Just tmux to start a session, then vim file.texto open your file, then C-b c to switch to a new terminal session within tmux, then latexmk -pdf file (or whatever your preferred compilation commands are). Then mupdf file.pdf or whatever PDF viewer you have. If you are on Linux and use something like evince you can just evince file.pdf & and the PDF will stay open and will auto-update when you recompile. You can compile in one window and then switch back to the other to edit. – musarithmia May 2 '17 at 21:51

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

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.