General question

How you can manually load a particular package from Vim-LaTeX in Vim and how it can be automated for every LaTeX file?

I am not interested in copying relevant parts from scripts of particular package to .vimrc as a workaround.

Specific problem

This is just a supplementary part to explain how solving such problem may be useful.

Short reminder

In The Not So Short Introduction to LaTeX 2ε you can read that:

A tilde ‘~’ character generates a space that cannot be enlarged and additionally prohibits a line break.

In Polish we should not leave short conjunctions at the end of line. ~ is helpful here, but writing it after conjunctions is cumbersome (and spoils the typing flow, and you can just forget about it sometimes).

Vim-LaTeX (vim-latexsuite package in debian; I am using version 20100129-2 in squeeze, just in case) provides per package additional customization. For Polish texts we use package polski in LaTeX and its Vim-LaTeX counterpart modifies space, so it automatically replaces space with tilde after short words.


For larger LaTeX documents splitting text between many files is a common practice. And here comes the problem with package detection in Vim-LaTeX. If I open the main .tex file (i.e. the one including other .tex files), where \usepackage{polski} is present, then space substitution works fine. It's not the file where you are writing much, thus it's not really useful here. But if I open any other .tex file (which is included by the main .tex file), which obviously does not have preamble (thereby there is no \usepackage{polski} in it), package detection fails, therefore space substitution is not working here.

Partial solution

I have figured out some partial flawed solution.

au FileType tex call Tex_pack_one('polski')

It's bad because it doesn't work if you open another .tex file in new window (via :sp or :vs for instance), even if this file have \usepackage{polski} (so it's a regression).

Simple testing. Go to insert mode and write i i i. You should see i~i~i. Open full LaTeX document (with preamble and \usepackage{polski}) in new window. Repeat the test there. Open third LaTeX document (w/o preamble) and repeat the test again.

Quote from my mail on vim-latex mailing list about using latex-master-file

Sent: Sun, May 22, 2011 at 11:23 (GMT+02:00)

I removed mentioned before au FileType tex call Tex_pack_one('polski') line from .vim.rc to avoid any clashes and added empty main.tex.latexmain file. From polski package PoV situation is the same as with my partial solution. Only first opened file works properly, another windows with .tex files do not.

I am starting to think that problem is in how package loading works internally in vim-latex (as oriented mostly for rarely used menus [correct me if I'm wrong], that should be extended only once) preventing executing packages' scripts more than once. Also polski package may have some bugs. I know Vim and can conveniently use its editing powers, but I haven't learned Vim scripting language yet (writing simple .vimrc doesn't require any special knowledge), thus I cannot judge here and need help of advanced Vim users/programmers.

  • I've started a thread at vim-latex mailing list.
    – przemoc
    May 22, 2011 at 9:31

1 Answer 1


Does adding this line to ~/.vim/after/ftplugin/tex.vim work?

call Tex_pack_one('polski')
  • No. Error detected while processing /home/przemoc/.vim/ftplugin/tex.vim: E117: Unknown function: Tex_pack_one. But even if there would be no error, then it would be very similar to autocmd approach I've used, so I doubt there would be any improvement at all. See also a link in the comment to the question.
    – przemoc
    May 23, 2011 at 21:24
  • My mistake, that should have been: ~/.vim/after/ftplugin/tex.vim (I have edited my answer.)
    – Heptite
    May 24, 2011 at 4:50
  • As predicted, it gives same results as my autocmd approach.
    – przemoc
    May 24, 2011 at 15:00
  • Then it looks like something in the LaTeX plugin is trying to be too clever by setting a global "state" variable to prevent loading a script, or portions of a script that have already been loaded. I don't use the LaTeX stuff at all, but I suspect that a buffer local variable should have been used in this instance instead.
    – Heptite
    May 24, 2011 at 16:44
  • Don't know the details, but I'm also suspecting something is wrong somewhere, as I expressed it on vim-latex mailing list (linked previously) in response to Aditya's mail (with useful suggestion about latex-master-file I wasn't aware before). Maybe I should add my delibarations to the question here...
    – przemoc
    May 24, 2011 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .