我正在尝试从Gedit更改突出显示文件。我已经修改了/usr/share/gtksourceview-3.0/language-specs/fortran.lang文件,因为我想更改编辑器将语句作为注释的情况。我的问题是,当我选择新的突出显示方案时,没有任何突出显示,而是仅保留为纯文本。
使用su权限打开了文件fortran.lang,我只是将所有内容复制粘贴到新的Gedit文件中,然后将其另存为fortran_enhanced.lang在同一文件夹中。我对原始文件所做的更改是:
原始的fortran.lang文件:
<language id="fortran" _name="Fortran 95" version="2.0" _section="Sources">
<metadata>
<property name="mimetypes">text/x-fortran</property>
<property name="globs">*.f;*.f90;*.f95;*.for</property>
<property name="line-comment-start">!</property>
</metadata>
<styles>
<style id="comment" _name="Comment" map-to="def:comment"/>
<style id="floating-point" _name="Floating Point" map-to="def:floating-point"/>
<style id="keyword" _name="Keyword" map-to="def:keyword"/>
<style id="intrinsic" _name="Intrinsic function" map-to="def:builtin"/>
<style id="boz-literal" _name="BOZ Literal" map-to="def:base-n-integer"/>
<style id="decimal" _name="Decimal" map-to="def:decimal"/>
<style id="type" _name="Data Type" map-to="def:type"/>
</styles>
<default-regex-options case-sensitive="false"/>
<definitions>
<!-- Note: contains an hack to avoid considering ^COMMON a comment -->
<context id="line-comment" style-ref="comment" end-at-line-end="true" class="comment" class-disabled="no-spell-check">
<start>!|(^[Cc](\b|[^OoAaYy]))</start>
<include>
<context ref="def:escape"/>
<context ref="def:in-line-comment"/>
</include>
</context>
(...)
修改的fortran_enhanced.lang文件:
<!-- Note: changed language id and name -->
<language id="fortran_enhanced" _name="Fortran 95 2.0" version="2.0" _section="Sources">
<metadata>
<property name="mimetypes">text/x-fortran</property>
<!-- Note: removed *.f and *.for from file extensions -->
<property name="globs">*.f90;*.f95;</property>
<property name="line-comment-start">!</property>
</metadata>
<styles>
<style id="comment" _name="Comment" map-to="def:comment"/>
<style id="floating-point" _name="Floating Point" map-to="def:floating-point"/>
<style id="keyword" _name="Keyword" map-to="def:keyword"/>
<style id="intrinsic" _name="Intrinsic function" map-to="def:builtin"/>
<style id="boz-literal" _name="BOZ Literal" map-to="def:base-n-integer"/>
<style id="decimal" _name="Decimal" map-to="def:decimal"/>
<style id="type" _name="Data Type" map-to="def:type"/>
</styles>
<default-regex-options case-sensitive="false"/>
<definitions>
<!-- Note: I want comments only beginning with !, not C -->
<context id="line-comment" style-ref="comment" end-at-line-end="true" class="comment" class-disabled="no-spell-check">
<start>!</start>
<include>
<context ref="def:escape"/>
<context ref="def:in-line-comment"/>
</include>
</context>
(...)
我已经阅读过此问题[ 傻瓜的自定义gedit语法突出显示?],并尝试使新的fortran_enhanced.lang文件可读
$ cd /usr/share/gtksourceview-3.0/language-specs
$ sudo chmod 0644 fortran_enhanced.lang
但这没什么区别。
我不得不说,我以前从未做过这样的事情,而且我什至都不了解大多数语言文档,因此我对所有批评持开放态度,因为我纯粹是凭直觉进行指导的。
谢谢高级!
cd /usr/share/gtksourceview-3.0/language-specs
。那是您实际运行的命令吗?如果是这样,则只需将文件移至/usr/local/share/gtksourceview-3.0/language-specs
。