! Highlighting Patterns for BibTeX ! ! http://volker.dnsalias.net/soft/nedit/ ! ! Tested with NEdit 5.4. ! ! Load this file by starting nedit with: ! ! nedit -import ! ! Then, check that the patterns were loaded correctly, and choose Save Defaults ! from the Preferences menu. The new patterns will now be incorporated into ! your own .nedit file, so the next time you start NEdit, you will no longer ! need to use -import. ! ! This language mode is currently called "BibTeX KW", for keyword, because ! certain BibTeX identifiers are highlighted differently. I might make another ! language mode "BibTeX" where that is not the case. Once loaded, language modes ! can be renamed with ! preferences->default settings->syntax highlighting->recognition patterns ! ->add/modify language mode, and editing the name. ! ! ChangeLog: ! Original version: Daniel Blezek, blezek.daniel@mayo.edu ! 10 March 2000, Updated for NEdit 5.1 (MWE) ! 30 Dec 2003: Volker Kuhlmann , NEdit 5.4 ! Substantial improvements: ! - Highlighting of month names, digits, and macro names ! - @String definitions now work ! - BibTeX doesn't distinguish between {..} and ".." as field value ! delimiter, therefore there's not much point using different colours ! for the value ! - If the nesting level of braces is exceeded for the field value, things ! break very badly for several entries thereafter. Increased levels ! which are handled correctly from 2 to 4 ! - The standard entry typed and fields are highlighted in a different ! colour ! - Field names are in a different colour if the previous entry is missing ! a trailing comma. ! If you have an idea for how to make this bright read instead, please ! let me know! ! - Removed style "BibTeX Field", using "Keyword" instead ! - Added style "BibTeX newfield", for non-standard entry fields ! (currently set to dark brown, style "plain" might be good choice too) ! - Renamed BracketString to BraceString ! 31 Dec 2003: Volker Kuhlmann ! - The "scroll entry" macro was missing its last line - ooops! ! Thanks to Matthias Odisio for pointing it out. ! - Added more comments to this file. ! - @Preamble now highlighted ! - errornous at-signs in comments are highlighted in bright red ! nedit.languageModes: \ BibTeX KW:.bib:::::: nedit.highlightPatterns: \ BibTeX KW:2:0{\n\ Entry:"(?i(?:(?:(@(?:article|book|booklet|inbook|incollection|inproceedings|manual|mastersthesis|misc|phdthesis|proceedings|techreport|unpublished))|(@[a-z][a-zA-Z0-9]+))\\s*\\{\\s*(\\S+)\\s*(?=,)|(@string)\\s*\\{\\s*(\\S+)\\s*=)|(@preamble)\\s*\\{|(@\\s*\\w+))":"}"::Plain::\n\ StandardType:"\\1":""::BibTeX type:Entry:C\n\ NewType:"\\2":""::Warning:Entry:C\n\ Ref:"\\3":""::Text Key:Entry:C\n\ Type:"\\4":""::BibTeX type:Entry:C\n\ Ref:"\\5":""::Text Key:Entry:C\n\ StandardType:"\\6":""::BibTeX type:Entry:C\n\ ErrType:"\\7":""::Flag:Entry:C\n\ Field:",[\\s\\n]*(?:(address|author|booktitle|chapter|crossref|edition|editor|howpublished|institution|journal|key|month|note|number|organization|pages|publisher|school|series|title|type|volume|year)|(\\S+))\\s*=":::Plain:Entry:\n\ StandardField:"\\1":""::Keyword:Field:C\n\ NewField:"\\2":""::BibTeX newfield:Field:C\n\ Number:"<[\\d.]+>":::Text Arg1:Entry:\n\ Month:"<(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|([^{"",]+))>":::Text Arg:Entry:\n\ StringVal:"\\1":""::Text Arg2:Month:C\n\ BraceString:"\\{":"}"::String2:Entry:\n\ QuoteString:"""":""""::String2:Entry:\n\ SubString:"\\{":"}"::String:BraceString:\n\ SubString:"\\{":"}"::String:QuoteString:\n\ Sub2String:"\\{":"}"::String1:SubString:\n\ Sub3String:"\\{":"}"::Plain:Sub2String:\n\ Comment:"%":"$"::Plain::D\n\ } nedit.styles: \ BibTeX type:blue:Bold Italic\n\ BibTeX newfield:SaddleBrown:Bold ! This macro scrolls the start of the next BibTeX entry to the top of the ! window. Remove if you don't want it. nedit.macroCommands: \ scroll entry@BibTeX KW:Shift+Ctrl+N::: {\n\ # Scroll next BibTeX entry to top of window\n\ end_of_line()\n\ find("@\\\\w+\\\\s*\\\\{", "forward", "regex", "nowrap")\n\ beginning_of_selection()\n\ scroll_to_line($line)\n\ beginning_of_line()\n\ }\n