Phase Portrait

Wednesday, March 05, 2008

Vim-LaTeX, Vim 7.0, and the filetype plugin

It's strange to me that this isn't better documented. On the other hand, Vim-LaTeX hasn't been maintained for AGES...

If you're using Vim-LaTeX with Vim 7 or higher, you should make sure you have this somewhere in your .vimrc:
" Prevents Vim 7.0 from setting filetype to 'plaintex'
let g:tex_flavor='latex'

Otherwise, your .tex files will not automatically kick off vim-latex on opening!

So, if you're having problems getting Vim-LaTeX to load when Vim opens a .tex file, try making that change (as well as all of the filetype plugin changes to your .vimrc that are documented).

Labels: , , , , ,

10 Comments:

  • Thank you-- I'd noticed the odd behavior and had just skipped around it by running gVim (which didn't seem to suffer the same problems).

    By Blogger Rhys Ulerich, at 8:36 AM  

  • My GUESS is that you are using an old version of gVim that is based on Vim6.0. If you update to the latest version of gVim, which is based on Vim7, you'll have the same problem.

    In either case, fixing the tex_flavor will fix the "problem."

    By Blogger Ted, at 9:26 AM  

  • This post has been removed by the author.

    By Blogger Sven Siegmund, at 11:15 AM  

  • Thank you for this post. It saved my day. Now when I run "gvim newfile.tex" it loads the menus. But still I cannot get the prepared preamble. The new file is completely empty /-:

    By Blogger Sven Siegmund, at 11:16 AM  

  • Sven -- You should try

    :help latex-suite

    and read some of the instructions there. The templates aren't supposed to show up automatically (though, you could configure Vim to do that). However, there are lots of shortcuts.

    For example, in insert mode, type:

    EDO

    You'll get a simple document class setup. Hit CNTRL+J to jump from fill-in-area to fill-in-area.

    Or, try typing:

    :TTemplate

    without any arguments. You'll get a menu with a few sample templates. You can choose one. In fact, you could choose one by passing an argument directly:

    :TTemplate article

    Check out the latex-suite documentation (:help latex-suite) for more information. In particular, check out chapter 3.

    Additionally, try doing

    :help latex

    You should find a pretty comprehensive LaTeX manual.

    By Blogger Ted, at 12:28 PM  

  • Any idea how to avoid extra whitespace in custom templates stored within ~/.vim/ftplugin/latex-suite/templates
    ?

    The default templates all work well, but when I load up a custom template I see lots of extra indentation (similar to what happens when pasting into vim without using ':set paste').

    By Blogger Rhys Ulerich, at 1:09 PM  

  • Rhys -- What do you have your "shiftwidth" set to? Type:

    :set sw?

    That's the number of spaces used for the autoindenting. Try doing:

    :set sw=2

    and then calling up a template. I think that indenting will get fixed. Type:

    :help shiftwidth

    for more information.

    By Blogger Ted, at 1:39 PM  

  • Shiftwidth doesn't seem to have any effect. For a template like this example
    I see results like this.

    I see the same behavior if my template uses either leading spaces or tab characters. From looking through the presupplied templates that ship with latex-suite, it seems none of them have leading line indentation.

    By Blogger Rhys Ulerich, at 4:30 PM  

  • OK. Your example helped me see what was going on. I thought you were exaggerating about the "set paste," but you actually ARE getting stairstepping.

    You should notice that the pre-packaged Vim-LaTeX templates do not have *any* indenting, and so they don't have the problem. That is, if you do:

    :TTemplate IEEEtran

    the resulting text does not get stairstepped. That is, it's indented with your "shiftwidth" settings.

    In your case, you've put your indenting within your template. That's the problem.

    If you actually issue:

    :set paste

    it will fix the problem. That is,

    :TTemplate stuff

    will give you the output you want (where indents are set by "shiftwidth," as explained).

    Otherwise, you should remove the indenting from your template.

    Vim-LaTeX could be changed so that it automatically does a ":set paste" and ":set nopaste" before and after the :TTemplate call, but I think the authors were worried that people would have one indenting convention (tabs, spaces, and different shiftwidths) and the template would have another. So, by stripping out indenting, they let Vim indenting based on how you've set it up to indent.

    Does that help?

    By Blogger Ted, at 8:53 AM  

  • Using :set paste before :TTemplate works like a charm. Thank you.

    By Blogger Rhys Ulerich, at 1:13 PM  

Post a Comment

Links to this post:

Create a Link

<< Home


 
appalling
appalling
appalling
appalling appalling
appalling
appalling
appalling