1" Vim syntax file 2" Language: BibTeX (bibliographic database format for (La)TeX) 3" Maintainer: Bernd Feige <[email protected]> 4" Filenames: *.bib 5" Last Change: 2017 Sep 29 6 7" Thanks to those who pointed out problems with this file or supplied fixes! 8 9" Initialization 10" ============== 11" quit when a syntax file was already loaded 12if exists("b:current_syntax") 13 finish 14endif 15 16let s:cpo_save = &cpo 17set cpo&vim 18 19" Ignore case 20syn case ignore 21 22" Keywords 23" ======== 24syn keyword bibType contained article book booklet conference inbook 25syn keyword bibType contained incollection inproceedings manual 26syn keyword bibType contained mastersthesis misc phdthesis 27syn keyword bibType contained proceedings techreport unpublished 28syn keyword bibType contained string preamble 29 30syn keyword bibEntryKw contained address annote author booktitle chapter 31syn keyword bibEntryKw contained crossref edition editor howpublished 32syn keyword bibEntryKw contained institution journal key month note 33syn keyword bibEntryKw contained number organization pages publisher 34syn keyword bibEntryKw contained school series title type volume year 35 36" biblatex keywords, cf. http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf 37syn keyword bibType contained mvbook bookinbook suppbook collection mvcollection suppcollection 38syn keyword bibType contained online patent periodical suppperiodical mvproceedings reference 39syn keyword bibType contained mvreference inreference report set thesis xdata customa customb 40syn keyword bibType contained customc customd custome customf electronic www artwork audio bibnote 41syn keyword bibType contained commentary image jurisdiction legislation legal letter movie music 42syn keyword bibType contained performance review software standard video 43 44syn keyword bibEntryKw contained abstract isbn issn keywords url 45syn keyword bibEntryKw contained addendum afterwordannotation annotation annotator authortype 46syn keyword bibEntryKw contained bookauthor bookpagination booksubtitle booktitleaddon 47syn keyword bibEntryKw contained commentator date doi editora editorb editorc editortype 48syn keyword bibEntryKw contained editoratype editorbtype editorctype eid entrysubtype 49syn keyword bibEntryKw contained eprint eprintclass eprinttype eventdate eventtitle 50syn keyword bibEntryKw contained eventtitleaddon file foreword holder indextitle 51syn keyword bibEntryKw contained introduction isan ismn isrn issue issuesubtitle 52syn keyword bibEntryKw contained issuetitle iswc journalsubtitle journaltitle label 53syn keyword bibEntryKw contained language library location mainsubtitle maintitle 54syn keyword bibEntryKw contained maintitleaddon nameaddon origdate origlanguage 55syn keyword bibEntryKw contained origlocation origpublisher origtitle pagetotal 56syn keyword bibEntryKw contained pagination part pubstate reprinttitle shortauthor 57syn keyword bibEntryKw contained shorteditor shorthand shorthandintro shortjournal 58syn keyword bibEntryKw contained shortseries shorttitle subtitle titleaddon translator 59syn keyword bibEntryKw contained urldate venue version volumes entryset execute gender 60syn keyword bibEntryKw contained langid langidopts ids indexsorttitle options presort 61syn keyword bibEntryKw contained related relatedoptions relatedtype relatedstring 62syn keyword bibEntryKw contained sortkey sortname sortshorthand sorttitle sortyear xdata 63syn keyword bibEntryKw contained xref namea nameb namec nameatype namebtype namectype 64syn keyword bibEntryKw contained lista listb listc listd liste listf usera userb userc 65syn keyword bibEntryKw contained userd usere userf verba verbb verbc archiveprefix pdf 66syn keyword bibEntryKw contained primaryclass 67 68" Non-standard: 69" AMS mref http://www.ams.org/mref 70syn keyword bibNSEntryKw contained mrclass mrnumber mrreviewer fjournal coden 71 72" Clusters 73" ======== 74syn cluster bibVarContents contains=bibUnescapedSpecial,bibBrace,bibParen,bibMath 75" This cluster is empty but things can be added externally: 76"syn cluster bibCommentContents 77 78" Matches 79" ======= 80syn match bibUnescapedSpecial contained /[^\\][%&]/hs=s+1 81syn match bibKey contained /\s*[^ \t}="]\+,/hs=s,he=e-1 nextgroup=bibField 82syn match bibVariable contained /[^{}," \t=]/ 83syn region bibComment start=/./ end=/^\s*@/me=e-1 contains=@bibCommentContents nextgroup=bibEntry 84syn region bibMath contained start=/\(\\\)\@<!\$/ end=/\$/ skip=/\(\\\$\)/ 85syn region bibQuote contained start=/"/ end=/"/ skip=/\(\\"\)/ contains=@bibVarContents 86syn region bibBrace contained start=/{/ end=/}/ skip=/\(\\[{}]\)/ contains=@bibVarContents 87syn region bibParen contained start=/(/ end=/)/ skip=/\(\\[()]\)/ contains=@bibVarContents 88syn region bibField contained start="\S\+\s*=\s*" end=/[}),]/me=e-1 contains=bibEntryKw,bibNSEntryKw,bibBrace,bibParen,bibQuote,bibVariable 89syn region bibEntryData contained start=/[{(]/ms=e+1 end=/[})]/me=e-1 contains=bibKey,bibField,bibComment3 90" Actually, 5.8 <= Vim < 6.0 would ignore the `fold' keyword anyway, but Vim<5.8 would produce 91" an error, so we explicitly distinguish versions with and without folding functionality: 92syn region bibEntry start=/@\S\+\s*[{(]/ end=/^\s*[})]/ transparent fold contains=bibType,bibEntryData nextgroup=bibComment 93syn region bibComment2 start=/@Comment\s*[{(]/ end=/^\s*[})]/me=e-1 contains=@bibCommentContents nextgroup=bibEntry 94" biblatex style comments inside a bibEntry 95syn match bibComment3 "%.*" 96 97" Synchronization 98" =============== 99syn sync match All grouphere bibEntry /^\s*@/ 100syn sync maxlines=200 101syn sync minlines=50 102 103" Highlighting defaults 104" ===================== 105" Define the default highlighting. 106" Only when an item doesn't have highlighting yet 107 108hi def link bibType Identifier 109hi def link bibEntryKw Statement 110hi def link bibNSEntryKw PreProc 111hi def link bibKey Special 112hi def link bibVariable Constant 113hi def link bibUnescapedSpecial Error 114hi def link bibComment Comment 115hi def link bibComment2 Comment 116hi def link bibComment3 Comment 117 118let b:current_syntax = "bib" 119 120let &cpo = s:cpo_save 121unlet s:cpo_save 122