sponsor Vim development Vim logo Vim Book Ad

bib_autocomp.vim : Autocompletion of BibTeX entries

 script karma  Rating 6/3, Downloaded by 1029  Comments, bugs, improvements  Vim wiki

created by
Petr Zemek
 
script type
ftplugin
 
description
  This filetype plugin does autocompletion of BibTeX entries in *.bib files.
  When you type the beginning of a BibTeX entry (e.g. @article{), it will
  try to complete it. The completed result might then look like this
  (see configuration options for customization):
    @article{<cursor position>,
      author = {},
        title = {},
        journal = {},
        year = {}
    }

  Configuration options for this plugin (you can set them in your $HOME/.vimrc):
   - g:bib_autocomp_enable (0 or 1, default 1)
       Enables/disables this plugin.
   - g:bib_autocomp_tag_indent (string, default "\<Tab>")
       Indention of tags inside a BibTeX entry. So for example, if you want
       each tag to be indented by four spaces, set this to "    ". Or if
       you want to indent by two tabs, set this to "\<Tab>\<Tab>".
   - g:bib_autocomp_tag_content_enclosing (string, default '{}')
       Enclosing of a tag content. If you prefer quotes to curly brackets,
       set this to '""' (the tag will then look like this: author = "").
   - g:bib_autocomp_trim_last_comma (0 or 1, default 1)
       When set to 1, it will omit the last comma in the tag list (so
       the result will look as the @article one in the previous paragraph).
       If you want to keep the comma after the last tag, set this to 0.
   - g:bib_autocomp_special_entries (list of strings, default ['string',
       'preamble', 'comment'])
       List of entries, which are considered "special". A special entry
       is not a type of a publication, so these entries will be completed
       just with the enclosing curly brackets, e.g. @comment{}
       (see http://www.bibtex.org/Format/ for more info).
   - g:bib_autocomp_entry_mapping (dictionary, read on for info)
       This dictionary defines a mapping between a BibTeX entry name
       and the list of tags it should contain. It is by default initialized
       to all standard entries (see http://en.wikipedia.org/wiki/Bibtex)
       and all required tags for each entry are inserted.
       If you want to add some entry or change the list of tags, set the
       configuration variable in your configuration file as follows:
         let g:bib_autocomp_entry_mapping = {
           \ 'entry-name': ['first-tag', 'second-tag', ...]
           \ }
       So for example, if you want to change the list of tags for the
       @misc entry, set the variable in this fashion:
         let g:bib_autocomp_entry_mapping = {
           \ 'misc': ['author', 'title', 'howpublished', 'url']
           \ }
       If you also want to add some custom entry, then use this template:
         let g:bib_autocomp_entry_mapping = {
           \ 'misc': ['author', 'title', 'howpublished', 'url'],
           \ 'custom': ['author', 'title', 'url']
           \ }
       As you can see, it is just a dictionary written in the Vimscript
       language.

Requirements:
  - filetype plugin must be enabled (a line like 'filetype plugin on' must
    be in your $HOME/.vimrc [*nix] or %UserProfile%\_vimrc [MS Windows])

Installation Details:
  Put this file into your $HOME/.vim/ftplugin directory [*nix]
  or %UserProfile%\vimfiles\ftplugin folder [MS Windows].

Notes:
This script is by all means NOT perfect, but it works for me and suits my
needs very well, so it might be also useful for you. Your feedback,
opinion, suggestions, bug reports, patches, simply anything you have
to say is welcomed!

Changelog:
  1.0 (2009-08-11)
    - Initial release version of this script.
 
install details
Put this file into your $HOME/.vim/ftplugin directory [*nix] or %UserProfile%\vimfiles\ftplugin folder [MS Windows].
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
bib_autocomp.vim 1.0.1 2009-08-15 7.0 Petr Zemek Documentation changes.
bib_autocomp.vim 1.0 2009-08-11 7.0 Petr Zemek Initial upload
ip used for rating: 3.19.56.45

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github