How can i set syntax highlight in gedit for html.erb file as ruby file?
How can i set syntax highlight in gedit for html.erb file as ruby file?
I tried these, doesn't wo开发者_如何学运维rk. Syntax highlighting in gedit not working automatically
Oh! I got the solution.
You need to install Gmate in Ubuntu. GMate is a collection of plugins, themes/styles and other improvements to get TextMate-like features in Gedit. Type the following commands to install Gmate.
sudo apt-add-repository ppa:ubuntu-on-rails/ppa
sudo apt-get update
sudo apt-get install gedit-gmate
When you are finished open your a .html.erb
and voila! there it is.
More info visit https://github.com/gmate/gmate#readme
You can change the highlighting preference from the drop-down list on the status bar. See if there is an option for RHTML present. If there isn't, you can follow this post to install it in: here. That's what I did, it works for me.
This method works for me. It's taken from this article. Unfortunately the commands showed there doesn't work because the files that we're supposed to download are not available. So here are the modified steps including the content of the files.
Create or override the file /usr/share/gtksourceview-2.0/language-specs/rhtml.lang
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<language id="rhtml" _name="RHTML" version="2.0" _section="Markup">
<metadata>
<property name="mimetypes">text/rhtml</property>
<property name="globs">*.rhtml</property>
</metadata>
<definitions>
<context id="erb-block">
<start><%</start>
<end>%></end>
<include>
<context ref="ruby:ruby:*"/>
</include>
</context>
<context id="rhtml">
<include>
<context ref="html:html"/>
<context ref="erb-block"/>
</include>
</context>
</definitions>
</language>
And also create or override the file /usr/share/mime/packages/rails.xml
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="text/rhtml">
<sub-class-of type="text/html"/>
<comment>RHTML Template</comment>
<glob pattern="*.rhtml"/>
<glob pattern="*.erb"/>
</mime-type>
<mime-type type="application/x-ruby">
<comment>Ruby JavaScript</comment>
<glob pattern="*.rjs"/>
</mime-type>
<mime-type type="application/x-ruby">
<comment>Ruby Rakefile</comment>
<glob pattern="Rakefile"/>
</mime-type>
<mime-type type="application/x-ruby">
<comment>Ruby Rake Task</comment>
<glob pattern="*.rake"/>
</mime-type>
<mime-type type="application/x-ruby">
<comment>Ruby XML Template</comment>
<glob pattern="*.rxml"/>
<glob pattern="*.builder"/>
</mime-type>
<mime-type type="text/x-yaml">
<comment>YAML Ain't Markup Language</comment>
<glob pattern="*.yml"/>
</mime-type>
</mime-info>
Then run sudo update-mime-database /usr/share/mime
.
You can manually change the highlighting preference from the drop-list on the status bar. If gedit can't recognize the file type, it assumes "plain text" by default.
I think I found a good solution: http://www.webupd8.org/2010/12/get-textmate-features-and-styles-in.html
If you use Debian then there is a package for the needed MIME types and syntax files: https://github.com/mkllnk/gedit-rails-extensions/releases
The package might also work with other Debian based distributions like Ubuntu. The contained files work in general with gedit and are system independend. They are similar to the files mentioned in other posts. But for newer Gnome versions the .lang files have to be in a newer directory:
/usr/share/gtksourceview-3.0/language-specs/
If you use Ubuntu and want more features than highlighting then GMate is supposed to be very good.
精彩评论