Gedit

From Octave
Revision as of 12:56, 5 December 2011 by Carandraug (talk | contribs) (Moved gedit section from the old wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Gedit is the Gnome text editor. There's many plugins and options that may be able to improve your experience while coding with octave.

syntax highlight

Gedit has very good syntax highlight for GNU octave, specially since v3 when it was split into matlab and octave. It uses gtksourceview for it and the latest lang file can be downloaded from repository.

Note that since matlab and GNU octave files have the same mimetypes and globs in gedit, your files may be highlighted using matlab rules. To easiest way to fix this is removing matlab.lang. The same happens with functions files which may be highlighted as Objective-C which can also be fixed by removing objc.lang. However, system updates may recreate these files and so you may want to keep removing these files.

The lang files usually reside at /usr/share/gtksourceview-3.0/language-specs

Code comment

One of the most useful plugins is code comment which allows to comment/uncomment several lines of code at the same. Simply select the lines and press Ctr+M to comment and Shift+Ctr+M to uncomment. There's one limitation though. While the syntax correctly recognizes both % and # as comment characters, the plugin must use only one. By default it uses #. If you want to change it to %, edit the file with the syntax highlight rule and in the metadata field change the value of line-comment-start:

<property name="line-comment-start">#</property>


Embedded Terminal

One of the gedit plugins allows to have an embedded terminal in the text editor window. By default, this terminal will show up on the bottom panel. If you prefer to move it to the side panel (maximize vertical space and see as many lines of code as possible), make the following changes on /usr/lib/gedit/plugins/terminal.py (or whatever your distro placed it).

261,262c261,262
<         side = window.get_side_panel()
<         side.add_item(self._panel, _("Terminal"), image)
---
>         bottom = window.get_bottom_panel()
>         bottom.add_item(self._panel, _("Terminal"), image)
265,266c265,266
<         side = self._window.get_side_panel()
<         side.remove_item(self._panel)
---
>         bottom = self._window.get_bottom_panel()
>         bottom.remove_item(self._panel)

Basically replace window.get_bottom_panel() with window.get_side_panel(). You might want to replace the side varname to bottom but that is not actually necessary. The same hack can be used on other plugins to move them between the panels.

File Browser on side panel

Another useful plugin is the File browser pane that allows to easily access files from the side pane and navigate into directories to see the paths. Would be great to implement a new one, octave specific, with all the paths in the function search path.