How can I force gedit to color code a file?

Asked by Kalle Hyvönen

I'm using gedit to write code for an Arduino project and the file extension is arduino's own .ino. Gedit does not recognize the format so it does not color the code. How can I tell gedit to color the code as C/C++ (cause it's just that with some other file extension)?

Edit: Hmm I just saved the file (it was saved before but not from gedit) and now the code is colored!

Gedit version 3.2.3.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gedit Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Curtis Hovey (sinzui) said :
#1

The following is content of ino.lang which I quickly made by reusing the c and c++ definitions.

mkdir ~/.local/share/gtksourceview-3.0/language-specs/
gedit ~/.local/share/gtksourceview-3.0/language-specs/ino.lang
copy the xml + language markup and paste it, save it, restart gedit.

<?xml version="1.0" encoding="UTF-8"?>
<!--

 This is a GtkSourceView language defintion.
 place in in ~/.local/share/gtksourceview-3.0/language-specs/

-->
<language id="ino" _name="Ardino" version="2.0" _section="Sources">
  <metadata>
    <property name="mimetypes">text/x-ardino</property>
    <property name="globs">*.ino</property>
      <property name="line-comment-start">//</property>
      <property name="block-comment-start">/*</property>
      <property name="block-comment-end">*/</property>
    </metadata>

    <styles>
        <style id="keyword" _name="Keyword" map-to="c:keyword"/>
        <style id="type" _name="Data Type" map-to="c:type"/>
        <style id="common-defines" _name="Common Defines" map-to="c:common-defines"/>
    </styles>

  <definitions>
    <!-- actual language definition: everything from C -->
    <context id="ino" class="no-spell-check">
      <include>
        <context ref="c:c"/>
        <context ref="cpp-proper"/>
      </include>
    </context>
  </definitions>
</language>

Revision history for this message
Kalle Hyvönen (scorper) said :
#2

The ino.lang does not seem to work. File stays uncolored.

Can you help with this problem?

Provide an answer of your own, or ask Kalle Hyvönen for more information if necessary.

To post a message you must log in.