Vim can use a keywords file(s) for completion. I setup two with the help of the biblatex cheatsheet (PDF):
(For the contents of these two files hosted here on this site rather than remotely, see below.)
Now, in my session I have to declare those files for use with the completion
Note that I made my test with the at sign in my entries file, but Vim
doesn't consider symbols here, unless it's tell (not tested and usable so)
to do so?
There's no way to put comments either, words after
" are read too.
Once the dictionaries
we're ready to complete based on them, after triggering a ^x
If happy with the files and that completion, add it permanently in your
~/.vimrc but only for Bib files and make the setting local in order to
not disturb the other buffers.
au FileType bib execute 'setlocal dict+=~/.vim/kwd/biber_entries.dict,~/.vim/kwd/biber_fields.dict'
au BufNewFile,BufRead *.bib execute 'let &l:dictionary .= "," . tr(expand("~/.vim/kwd/biber_*.dict"), "\n", ",")'
There's still one annoyance: continuously switching to dictionary completion
sub mode. By default, ^n and ^p, unless the
appropriate ^x switch, Vim scans: the current buffer (
buffers from other windows (
w), other loaded buffers that are in the
buffer list (
b), the unloaded buffers that are in the buffer list (
then do tag completion (
t). Let's change it to always use our words list
first, then the current buffer:
Now, we have homemade Bib files keywords completion, but also any
and even line
already there. (full line still require ^x^l and I
cannot found how to add that in the option.) Also, when pleased with that
save it to the
~/.vimrc and still ensure it's local. Good news, both
actions (defining desired completions and lookup files) can be done in one
" also make the following fileType dependent
Some people may prefer the use of
~/.vim/after/ftplugin/bib.vim which is
always associated to that file type (hence easier to write: this file is
triggered like an
autocmd fileType, the cons is that there're more to
backup and restore.) As I don't use
vimtex, I don't know which method is
more compatible with its
- Entries type may not be needed because you use
let you define nice input templates, just add yours for Bib files. I'm
also thinking to use such plugin, but for now I'm using abbreviations…
- There's no need to have two different files and it may be better to
have one global per file type… I did split because I feel more comfortable
working in smaller files.
- For switching between completion methods easily I'm planning to use
To be followed.
Here are the content of the
.dict files linked above
editora editorb editorc
title titleaddon origtitle shorttitle subtitle
booktitle booktitleaddon subbooktitle
maintitle maintitleaddon submaintitle