Gedit

From Octave
Revision as of 11:36, 30 November 2013 by Rezahousseini (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Gedit is the Gnome text editor. There are many plugins and options that may be able to improve your coding experience.

Syntax Highlighting[edit]

Gedit has very good syntax highlighting 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 their 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[edit]

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[edit]

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 variable name to bottom but that is not actually necessary, it's only so that the variables name reflect the truth about them. The same hack can be used on other plugins to move them between the panels.

File Browser on side panel[edit]

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.