# How to get vim-latex's \cite completion to work?

I'm having issues with \cite completion. In the screenshot below, you can see what I get when I do \cite{ } F9. It is not doing what documentation says it would do, such as:

• Show a list that I can explore using n and p. n and p don't do anything.
• Show the ability to filter. f doesn't do anything.
• Also, if I remember correctly, it is supposed to search based on the few letters typed. So if I typed \cite{foo and then F9 it would show citations that start with foo. Instead, it is always showing me the list of citations starting at the same place, which happens to be the top of biblio.bib.

I recently set up my vim, so I am probably doing something wrong. Here is my .vimrc and, not that it matters, here are the tex files I am editing. You can see I do have a main.tex.latexmain file as recommended. I even tried setting biblio.bib's directory path in g:Tex_ProjectSourceFiles but it didn't solve the issue. I also tried disabling some of my other plugins by moving them to a different directory but didn't help either. Am I missing something obvious?

-

I hve the same problem with my archlinux laptop. After one night google and no result, I open the source code of vim-latex. In ~/.vim/ftplugin/latex-suite/texviewer.vim, I find the cite completion part:

 elseif exists("s:type") && s:type =~ 'cite'

let s:prefix = matchstr(s:prefix, '$$[^,]\+,$$*\zs$$[^,]\+$$\ze\$')
call Tex_Debug(":Tex_Complete: using s:prefix = ".s:prefix, "view")

if has('python') && Tex_GetVarValue('Tex_UsePython')
\ && Tex_GetVarValue('Tex_UseCiteCompletionVer2') == 1
exe 'cd '.s:origdir
silent! call Tex_StartCiteCompletion()


and Tex_StartCiteCompletion() finish the cite completion work as ref's said.

so, I think the problem comes from python.

I run python in my vim:

:python


and get an error:

E319: Sorry, the command is not available in this version


At this time, I thought i found the problem -- my vim not compile with python support. In Archlinux, the package vim has no python support, and the gvim has the full features. So, after install the gvim, everythings OK!

-
Some GNU/Linux distributions provide, by default, a lite version of vim, e.g. Ubuntu provides the package vim-tiny. A more complete version is the available as an option, e.g. the package vim in Ubuntu. To have support for Perl, Python and Tcl scripting a third version is often required, e.g. the package vim-gnome in Ubuntu. – mas Oct 18 '11 at 6:55
for the records: on opensuse standard vim package does not have python support. You have to install vim-python or vim-enhanced – Francesco Montesano Nov 14 '13 at 12:42
Same here for Ubuntu 16.04 -- one needs to install one of the vim-*-py2 packages, e.g. vim-gtk3-py2. – Norbert Schuch May 19 at 12:24

I would suggest setting up a minimal working example to confirm that the problem is with the gvim setup rather than in the other files and file locations.

In the same directory, a test .tex file of:

\documentclass{article}
\bibliographystyle{amsplain}
\begin{document}
test
\bibliography{TeX}
\end{document}


and a TeX.bib of

@book{diller97,
author = "Antoni Diller",
title = "{\LaTeX} Line by Line",
year = "1997",
edition = "1st",
publisher = "Wiley",
}

@book{goossens99,
author = "Michel Goossens and Sebastian Rahtz",
title = "The {\LaTeX} Web Companion",
year = "1999",
edition = "1st",
}


works for my set-up when adding the line \cite{} after the line test and then pressing F9.

A second check: is vim-latexsuite is working for other functions? For example, with gvim, there would usually be several 'TeX-...' entries on the main menu. vim-latexsuite on some systems must be both installed and then manually set up. For example, on Ubuntu 11.04, you have to set up latexsuite after installation via synaptic:

FWIW, my directory ~/.vim has subdirectories that include one, ftplugin, that, in turn, contains another subdirectory, latex-suite, but also two files: bib_latexSuite.vim and tex_latexSuite.vim. Unless you're also running Ubuntu 11.04 I would not expect exactly the same files but I would expect some files relating to latexsuite and to bib in the .vim directory in your home directory (if you are using GNU/Linux).

-
Thanks mas. I tried the example and I have the same results. What is weird, is that it doesn't even show the entries in TeX.bib when pressing F9. Instead, it showed the entries in my other bib file in the same directory. This is probably due to main.tex.latexmain. – amh Aug 23 '11 at 14:00
I also tried doing the experiment on a different directory. I mkdir foobar and created test.tex and TeX.bib in there. Then I did the test. When pressing <F9> nothing happened! I do have the Tex- entries on the main menu. – amh Aug 23 '11 at 14:01
@andresmh. Sorry that was no help. I take it that latexsuite is working for other functions? I have added a note about some files I have in .vim, just in case you are running a similar OS and made the test file compilable (in case that is relevant -- it wasn't for me) .Hopefully someone else will have better ideas! – mas Aug 23 '11 at 14:58
Thanks. Yes, the rest of the latexsuite functions work. I am running Ubuntu 10.10. I am also using vim's pathogen, which might be the problem. I think I am going to go back to vanilla vim. – amh Aug 23 '11 at 16:05
@andresmh -- One passing thought: F9 in \cite{} is reported not to work if there is a space in the path to the bib file(s) or a space after the { in the database entry. I doubt either of these is a problem for you. A similar problem has been reported on this site before but was closed as 'off topic'. If that happens to this one you might like to try the UbuntuForums, for example. – mas Aug 23 '11 at 21:39

On ubuntu 12.04, I have installed manually vim (version 7.4), and vim-latex with pathogen. I only fixed this issue when I enabled python on vim (./configure --enable-pythoninterp=yes).

I didn't seem to be able to get this feature working with the vim packages from the repository, although admittedly I didn't try vim-gnome, as suggested above.

EDIT:

Also, latex-suite seems to seek for the expression \bibliography{} in the main file, regardless whether this expression is commented or not, so if there are several\bibliography{}'s commented, with not valid paths in them, it won't work, as it cannot tell commented lines, and it will unsuccessfully try to parse those paths.

-

I had the same problem. The functionality seems only to work when vim-latex is installed manually and not via a package-manager like vundle, pathogen, NeoBundle etc. After de-installing it via the package-manager and installing it manually everything worked fine.

-

I'm also experiencing this problem, sometimes.

I could fix it in one case by renaming foo.latexmain to foo.tex.latexmain. I always thought the former is also valid, I'm not sure anymore. Also in this case, the bib-file is foo.bib.

-

I was having the same issue with LaTeX-Suite using my Mac. My <F9> was mapped to another function (view all windows). I changed the file ~/.vim/ftplugin/latex-suite/texviewer.vim so that <F9> was replaced with <F8> (or whatever key you want to map function to that is available). That worked for me. (Alternatively you could probably edit your settings so that <F9> doesn't do anything on Mac OS)

Exact steps in shell and vi:

1. vi ~/.vim/ftplugin/latex-suite/texviewer.vim
2. :%s/<F9>/<F8>/g
-