Geany:bibtex文件的自定义语法高亮(* .bib)

时间:2016-08-18 03:53:46

标签: syntax-highlighting geany

默认情况下,* .bib文件假定geany中乳胶文件的语法高亮显示。 但是,我想更改.bib文件的语法高亮。

我为bibtex创建了一个文件定义:

~/.config/geany/filedefs/filetype.Bibtex.conf

看起来像这样:

# Geany Color Syntax support for Gnuplot 4.2+
# version 0.1
# April 5, 2013


[styling]
# Edit these in the colorscheme .conf file instead
default=default
comment=comment_line
stringdq=string_1
stringlq=string_2
stringrq=string_2
function=keyword_1
variable=keyword_1,bold
label=label
userdefined=keyword_2,bold
sectiondef=keyword_1
subsectiondef=keyword_1
ifdefinedef=keyword_1
macrodef=keyword_1
stringvar=string_1
number=number_1
sectiongroup=keyword_1
pageex=keyword_1
functiondef=keyword_1
commentbox=comment


[keywords]
# all items must be in one line
variables=abstract address annote author booktitle chapter contents copyright  crossref doi edition editor institution isbn issn lccn journal key keywords month note number organization pages price publisher school series title type url language volume year
userdefined=article book booklet conference inbook incollection manual masterthesis misc phdthesis proceedings techreport unpublished


[lexer_properties]
nsis.uservars=1
nsis.ignorecase=1


[settings]
# default extension used when saving files
extension=bib

# single comments, like # in this file
comment_single=#
# multiline comments
#comment_open=
#comment_close=


# This setting works only for single line comments
comment_use_indent=true

# context action command (please see Geany's main documentation for details)
context_action_cmd=

# lexer filetype should be an existing lexer that does not use lexer_filetype itself
lexer_filetype=NSIS


[build-menu]
EX_00_LB=Execute
EX_00_CM=rm fit.log; galfit %e.gal; rm galfit.0*; open fit.log
EX_00_WD=
FT_00_LB=
FT_00_CM=
FT_00_WD=
FT_02_LB=
FT_02_CM=
FT_02_WD=

然后,我在文件中包含了文件扩展名:

~/.config/geany/filetype_extensions.conf

现在假设我有一个示例bib文件,例如 bibtex3.bib看起来像这样:

@article{einstein,
  author =       "Albert Einstein",
  title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
                 [{On} the electrodynamics of moving bodies]",
  journal =      "Annalen der Physik",
  volume =       "322",
  number =       "10",
  pages =        "891--921",
  year =         "1905",
  DOI =          "http://dx.doi.org/10.1002/andp.19053221004"
}

但我仍然没有看到.bib文件的语法高亮。

一些相关链接:
http://www.geany.org/manual/0.14/#filetype-extensions
Custom syntax highlighting in Geany
Make Geany recognize additional file extensions

问题:如何在geany中自定义语法高亮.bib文件?

1 个答案:

答案 0 :(得分:0)

默认情况下,.bib文件与Latex相关联。 更改以下文件:

~/.config/geany/filetype_extensions.conf

看起来像这样:

# Filetype extension configuration file for Geany
# Insert as many items as you want, separate them with a ";".
# See Geany's main documentation for details.
[Extensions]
Abaqus=*.inp;
Abc=*.abc;*.abp;
ActionScript=*.as;
Ada=*.adb;*.ads;
Asciidoc=*.asciidoc;*.adoc;
ASM=*.asm;*.asm51;*.a51;
Batch=*.bat;*.cmd;*.nt;
CAML=*.ml;*.mli;
C=*.c;*.xpm;
C++=*.cpp;*.cxx;*.c++;*.cc;*.h;*.hpp;*.hxx;*.h++;*.hh;*.C;*.H;
Clojure=*.clj;*.cljs;*.cljc;
CUDA=*.cu;*.cuh;*.h;
C#=*.cs;
CMake=CMakeLists.txt;*.cmake;*.ctest;
COBOL=*.cob;*.cpy;*.cbl;*.cobol;
CoffeeScript=*.coffee;Cakefile;*.Cakefile;*.coffee.erb;*.iced;*.iced.erb;
Conf=*.conf;*.ini;config;*rc;*.cfg;*.desktop;*.properties;
CSS=*.css;
Cython=*.pyx;*.pxd;*.pxi;
D=*.d;*.di;
Diff=*.diff;*.patch;*.rej;
Docbook=*.docbook;
Erlang=*.erl;*.hrl;
F77=*.f;*.for;*.ftn;*.f77;*.F;*.FOR;*.FTN;*.fpp;*.FPP;
Ferite=*.fe;
Forth=*.fs;*.fth;
Fortran=*.f90;*.f95;*.f03;*.f08;*.F90;*.F95;*.F03;*.F08;
FreeBasic=*.bas;*.bi;*.vbs;
Genie=*.gs;
GLSL=*.glsl;*.frag;*.vert;
Go=*.go;
Graphviz=*.gv;*.dot;
Haskell=*.hs;*.lhs;*.hs-boot;*.lhs-boot;
Haxe=*.hx;
HTML=*.htm;*.html;*.shtml;*.hta;*.htd;*.htt;*.cfm;*.tpl;
Java=*.java;*.jsp;
Javascript=*.js;
JSON=*.json;
LaTeX=*.tex;*.sty;*.idx;*.ltx;*.latex;*.aux;
Lisp=*.lisp;
Lua=*.lua;
Make=*.mak;*.mk;GNUmakefile;makefile;Makefile;makefile.*;Makefile.*;*.make;
Markdown=*.mdml;*.markdown;*.md;*.mkd;*.mkdn;*.mdwn;*.mdown;*.mdtxt;*.mdtext;
Matlab/Octave=*.m;
NSIS=*.nsi;*.nsh;
Objective-C=*.m;*.mm;*.h;
Pascal=*.pas;*.pp;*.inc;*.dpr;*.dpk;
Perl=*.pl;*.perl;*.pm;*.agi;*.pod;
PHP=*.php;*.php3;*.php4;*.php5;*.phtml;
Po=*.po;*.pot;
Python=*.py;*.pyw;SConstruct;SConscript;wscript;
PowerShell=*.ps1;*.psm1;
reStructuredText=*.rest;*.reST;*.rst;
R=*.R;*.r;
Rust=*.rs;
Ruby=*.rb;*.rhtml;*.ruby;*.gemspec;Gemfile;rakefile;Rakefile;
Scala=*.scala;*.scl;
Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.mksh;*.zsh;*.ash;*.bash;.bashrc;bash.bashrc;.bash_*;bash_*;*.m4;PKGBUILD;*profile;
SQL=*.sql;
Tcl=*.tcl;*.tk;*.wish;
Txt2tags=*.t2t;
Vala=*.vala;*.vapi;
Verilog=*.v;
VHDL=*.vhd;*.vhdl;
XML=*.xml;*.sgml;*.xsl;*.xslt;*.xsd;*.xhtml;*.xul;*.dtd;*.xtpl;*.mml;*.mathml;
YAML=*.yaml;*.yml;
Zephir=*.zep;
None=*;

# Note: restarting is required after editing groups
[Groups]
Programming=Clojure;CUDA;Cython;Genie;Scala;
Script=Graphviz;
Markup=
Misc=JSON;
None=

现在,进行以下更改:

LaTeX=*.tex;*.sty;*.idx;*.ltx;*.latex;*.aux;

然后,新的文件定义应该适用于bibtex文件。

如果这不起作用: 打开所需的.bib文件。 文件> SetFiletype>脚本语言> Bibtex源文件。