# Biber backend and Vim-Latex

I'm trying to make biblatex work with Vim-Latex (a.k.a Latex-Suite). Using bibtex as a backend works fine but using biber doesn't. I'm using Miktex 2.9 and have the following in my .vimrc file:

" Latex configuration
set shellslash
set grepprg=grep\ -nH\ \$*
let g:tex_flavor='latex'
let g:Tex_BibtexFlavor = 'biber'
let g:Tex_CompileRule_pdf = 'pdflatex --synctex=-1 -src-specials -interaction=nonstopmode -file-line-error-style \$*'
let g:Tex_DefaultTargetFormat='pdf'
let g:Tex_MultipleCompileFormats='pdf'

I've also tried setting:

let g:Tex_CompileRule_bib = 'biber \$*'

But I still get the "There were undefined references" warning.

-
Do you setup biblatexcorrect with backend=biber? Did you delete old auxiliary files? –  Marco Daniel Nov 21 '12 at 19:14
Yes, I did all that. When setting biblatex with backend=bibtex it works fine but with biber it doesn't. Using biber in texmaker works perfectly so I believe the issue is related to the way vim is configured. –  petobens Nov 21 '12 at 19:28
The difference is probably that bibtex runs on the .aux file but biber uses the .bcf file. Perhaps vim is always calling the bib backend with file.aux? biber also accepts it if you call it with just the base file name file with no extension so perhaps there is a way to configure it to do this? –  PLK Nov 25 '12 at 21:57
May I suggest that you have a look at latexmk, if available on your system? It takes care of compiling LaTeX documents and supports biber as bibliographic back-end. Also, you might want to have a look at the LaTeX-Box Vim plugin. –  joelpet Jan 4 '13 at 4:37
@joelpet I'm using windows so I can't use Latex-Box with latexmk. –  petobens Mar 11 '13 at 1:19

As MarcoDaniel suggested, one possibility is to use the amazing arara tool. In order to make it work with Vim-Latex, the compiler settings in the vimrc must be:

let g:tex_flavor='latex'
let g:Tex_DefaultTargetFormat='pdf'
let g:Tex_CompileRule_pdf = 'arara -v \$*'

To be to able to jump to the error location in the source window by pressing enter in the "QuickFix" window you must pass the "file-line-error-style" flag to arara, for instance like this:

% arara: pdflatex: {options: "-file-line-error-style"}

To use biber then simply add the directive: % arara: biber

-

What I did was in the vim-latex plugin, in ~/.vim/ftplugin/latex-suite/texrc, I changed:

TexLet g:Tex_BibtexFlavor = 'bibtex'

to

TexLet g:Tex_BibtexFlavor = 'biber'

Then, like was mentioned by @PLK, you want biber to execute on the .bcf file (see section 3.11.1.1 of the biblatex manual), so in ~/.vim/ftplugin/latex-suite/compiler.vim around like 568, I changed

let bibFileName = mainFileName_root.'.bbl'

to

let bibFileName = mainFileName_root.'.bcf'

Let me know if that works for you.

-
Unluckily that doesn't work for me. –  petobens Jun 8 '13 at 14:55
This solution didn't work for me on its own, but with one more step, it worked. Just above the "let bibFileName" line in compiler.vim, there is a line "if runCount == 0 && Tex_IsPresentInFile('\\bibdata', mainFileName_root.'.aux')". You need to change the '\\bibdata' to a word that will actually be in your aux file if biber needs to be run. I used 'cite' instead but other things would probably work. –  Louisa Grey Dec 30 '13 at 18:08
@LouisaGrey, good catch. I had also edited that line. However, all I took out were the two \\ before bibdata and then change the extension at the end to bcf. bibdata still occurs as a word in the bcf file, so for me that still causes it to execute biber on the file. –  Paul Jan 9 '14 at 18:48

After the answer by Paul and Werner above didn't work for me, I did the following, based on what they wrote:

let g:Tex_BibtexFlavor = 'biber'
let g:Tex_DefaultTargetFormat="pdf"
" The following is relevant to make LaTeX rerun after biber if necessary:
" (include all formats for which re-running is to be enabled)
let g:Tex_MultipleCompileFormats='pdf,dvi'

In ~/.vim/ftplugin/latex-suite/compiler.vim around line 567, I did the following code replacement:

" old code:
" if runCount == 0 && Tex_IsPresentInFile('\\bibdata', mainFileName_root.'.aux')
"   let bibFileName = mainFileName_root.'.bbl'

" new code:
if runCount == 0 && Tex_IsPresentInFile('Please \(re\)run Biber on the file', mainFileName_root.'.log')
let bibFileName = mainFileName_root.'.bcf'

The change in the second line (.bbl -> .bcf) is relevant to make biber run on the correct file. The change in the first line has the effect that biber is only executed when LaTeX outputs the usual "Please (re)run Biber on the file ..." in the .log-File. In the version suggested above by Louisa Grey, biber would run anytime the source file contains a citation; but very often this is not necessary.

Please let me know if this works for you.

Edit: Sometimes it is convenient to run biber manually, not as part of the compilation process triggered by the \ll short key. For this you can configure a new short key \lb by simply adding the following line to ~/.vimrc: