5

I am a long time user of latex and I have been searching for a good editor to use it with. I have been using TexStudio but recently I feel I need the no distractions feel of using vim. So I stumbled upon vim-latex and here is where my problems started.

I went on their site and followed the instructions but I don't think they are complete or clear enough. I copied everything as per instructions but I can't make it work. Then there is the problem of usage. How does one use vim-latex? Is there a command, a key press?

Is vim-latex the best option for using latex in vim? Or should I look elsewhere?

Cheers

Edit: The details

1) Downloaded the archive from here

2) Unpacked the archive and ended up with a dir called vim-latex-1.10.0 which I then copied to my .vim dir 3) Then I went and did the changes in the .vimrc file, but I had to stop at the tex.vim because it wasn't where the instructions said it was supposed to be.

4) I started vim regardless and issued the helptags ~/.vim/doc command which didn't work. The output was E150: Not a directory: ~/.vim/doc

5) Regarding compilation: I know about reading the manuals and I usually do, but this particular one is not very clear at least to a noob like me when it comes to vim. Here is what it says at

Setting Compilation rules:

"In order to compile LaTeX files into various formats, Latex-Suite needs to know which external programs to call and in which way they need to be called. This information is provided to Latex-Suite via a number of "rules". For each format you want to compile to, you need to specify a rule. A rule is specified by defining a variable of the form:"

Where do you put these rules?

Now what should I do?

10
  • 2
    We'll need you to help us to help you :) "I copied everything": what did you copy exactly? Where did you put it? "but I can't make it work": What have you tried to do? Why do you say it doesn't work? What were you expecting and what do you get? Finally "Is there a command, a key press": you will have to read the doc at least a little bit.
    – statox
    Commented Nov 13, 2018 at 10:40
  • Did you notice following question on tex.stackexchange.com tex.stackexchange.com/questions/112698/how-to-install-vim-latex ?
    – Hotschke
    Commented Nov 13, 2018 at 10:50
  • @statox see the new edits please and thank you for your help.
    – lucian
    Commented Nov 13, 2018 at 11:14
  • 1
    @Lucian: Ok. At least, I now know that you already tried to use pathogen and vundle to install plugins. Did you manage to install successfully other plugin(s)? There is the general question on how to install plugins for vim vi.stackexchange.com/questions/613. Also do you know that there is a maintained github repository for vim-latex: github.com/vim-latex/vim-latex. I personally use vimtex another popular latex plugin for vim (according to stars on github it is more popular than vim-latex). I would recommend this instead of vim-latex.
    – Hotschke
    Commented Nov 13, 2018 at 11:34
  • 1
    For more details about vimtex, you should have a look at its README.md.
    – Hotschke
    Commented Nov 13, 2018 at 12:53

1 Answer 1

6

Installation into a Vim 8 packpath and an example vimrc

  1. ❯ git clone https://github.com/vim-latex/vim-latex ~/.vim/pack/my_latex_plugins/start/vim-latex

  2. Typically, you want at least following settings in your vimrc

    ❯ cat ~/.vim/vimrc
    filetype plugin on
    filetype indent on
    let g:tex_flavor='latex'
    

A minimal installation would look like visualized with tree:

~/.vim
❯ tree -L 5
.
├── pack
│   └── my_latex_plugins
│       └── start
│           └── vim-latex
│               ├── Makefile
│               ├── Makefile.in
│               ├── README.md
│               ├── compiler
│               ├── doc
│               ├── ftplugin
│               ├── indent
│               ├── latextags
│               ├── ltags
│               ├── plugin
│               └── vim-latex.metainfo.xml
└── vimrc

Mini Tutorial: Compile a Hello World in LaTeX to pdf

Create a new file with extension tex as following

❯ vim demo.tex

switch to insert mode (type i) and type

EDO

This will trigger a snippet and the buffer should now look like:

enter image description here

You can jump around with <C-j> to adjust the placeholders <++> for the documentclass options, the documentclass and begin typing the document:

I entered a Hello World equivalent for LaTeX with

<Backspace> + <C-j> + article + <C-j> + Hello World! which gives you:

enter image description here

Now press :w for saving the file and start compilation with <leader>ll. This is by default \ll. Note these are lower case L (not \11). Right now this starts latex on windows/linux which generates a dvi file (on a mac pdflatex is called by default). To get immediately a pdf on windows/linux, you have to configure vim-latex a little bit more. But first you should get acquainted with the manual of vim-latex:

In order to read the manual of vim-latex, you need to run

:helptags ALL

or

:helptags ~/.vim/pack/my_latex_plugins/start/vim-latex/doc 

to generate a so-called tags file so vim can find the manual.

You can now open the manual with :h latex-suite (not :h vim-latex).

There is a second help file, the quickstart tutorial under

:h latex-suite-quickstart

As a beginner you should take the time (30-40 min.) to go through the quickstart tutorial. It covers the basics of this feature rich plugin.

The settings for adjusting the compilation can be found under :h customizing-compiling which will tell you about

g:Tex_DefaultTargetFormat                                  *ls_11_6_1* *ls_a_dF*
                                                       *Tex_DefaultTargetFormat*


Type             String
Default Value    dvi for windows/*nix and pdf for mac

Use this setting to choose the default target format. For example, setting this
to pdf makes Latex-Suite compile a pdf file when you press \ll and fire up the
pdf viewer on pressing \lv. Make sure that a rules for compiling and viewing
have been defined for this target format as described here [|ls_a_dG|] and here
[|ls_a_dO|].

So on windows/linux you have to add following line to your vimrc to compile directly to pdf:

let g:Tex_DefaultTargetFormat = 'pdf'

I am on a mac where 'pdf' is already the default.

More questions about installation of vim-latex

If this answer does not help, consider also following questions with answers:

11
  • Hey, that worked! Thank you for also explaining what the <leader> was! One thing was different, the result was not a pdf but a dvi. How can I get a pdf?
    – lucian
    Commented Nov 13, 2018 at 12:06
  • Please see my additions to my answer about accessing the manual of vim-latex and the setting g:Tex_DefaultTargetFormat.
    – Hotschke
    Commented Nov 13, 2018 at 12:15
  • I get this error when I run :helptags ALL: E152: Cannot open /usr/share/vim/vim81/doc/tags for writing. And where do I add the let command? In the .vimrc?
    – lucian
    Commented Nov 13, 2018 at 12:18
  • you can ignore the helptags error. /usr/share/vim/vim81/doc/tags has not been changed and you cannot write to it. You basically only want to have all tag files updated that reside inside your ~/.vim/ directory Commented Nov 13, 2018 at 12:20
  • As said you can ignore this: The argument ALL tells vim to generate for the complete vim documentation the tag files. This is not necessary for the files under /usr/share/vim/vim81/doc/. I use ALL because it is easy to remember and short to type but actually not necessary.
    – Hotschke
    Commented Nov 13, 2018 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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