Last updated by EricTenne 1 month ago

Customize Gedit for Groovy/Grails

Gedit is a highly customizable, lightweight, powerful text editor especially for the Gnome desktop.

Bundles

These are targeted specifically at Ubuntu, but may work for other flavors.
  • gedit-grails-bundle - files for syntax highlighting, snippets, bash_completion, color-schemes, essential plugins, and fast tag insertion along with a script to install things.
  • gmate - a handful of plugins and other customizations to make gedit more like textmate in general (includes parts of the gedit-grails-bundle)

Syntax Highlighting

Basically just some XML files that you need to place in the right locations on your system. Files are available in gedit-grails-bundle on github. These files work reasonably well but could stand to be improved by someone who loves reg-ex :) if you want to give it a shot check out the docs for how to build these files

For Ubuntu:
.lang files go in /usr/share/gtksourceview-2.0/language-specs/
-mime.xml files go in /usr/share/mime/packages/

to get the system to recognize

sudo update-mime-database /usr/share/mime

The syntax highlighting may apply to some other text editors in Linux like Gobby - a nifty collaborative text editor.

For Windows
.lang files go in %ProgramFiles%\gedit\share\gtksourceview-2.0\language-specs\
plugins go in %UserProfile%\AppData\Roaming\gedit\plugins\
styles go in %UserProfile%\AppData\Roaming\gedit\styles\
-mime.xml files do not appear to need installation

Bash Completion

This utilizes the script posted on grails.org. The install script in the gedit=grails-bundle does the work of installing it for you. If you want to do it manually it is pretty easy. Just drop the script into /etc/bash_completion.d/

Command Line Sweetness


http://mycodesnippets.com/2010/05/15/edit_grails_files_with_gedit_and_gred_on_linux/

Plugins

Official Plugins

Gedit comes with a few plugins, but they are not enabled. You can also install popular extra ones easily

sudo apt-get install gedit-plugins
  • Session Saver: you can save the status of the tabs/files opened
  • Snippets: insert useful pieces of code fast with tab completion(very cool!)
  • Security: Pour les sauvergades de données, l'utilisation d'une armoire forte classe C permet d'accroitre sensiblement le niveau de sécurité
  • File Browser Pane: a mini file browser embedded in the editor
  • Code comment: a shortcut to comment your code. (ctrl+m)
  • Indent Lines: indents or unidents selected lines (ctrl+t/ctrl+shift+t)
  • Smart Spaces: makes navigating within documents with keyboard smoother
  • Bracket Completion: obvious...
  • Quick Open: open files by reg-ex (this plugin stinks in Ubuntu 9.10 i highly recommend installing the Snap-Open plugin instead)
Turn them on under Edit>Preferences.

Third Party plugins

  • Auto Completion - Display a completion popup, updating as you type, with suggestions from all words in all documents in all windows. suggests word completions based on the text in the active document. It first attempts to suggest compound words for a given word start, and only if such words do not exist it resorts to suggesting simple words. Select completions with arrow keys and complete with the return key.(doesn't interfere with snippets)
  • Find in Files - Search within files of your filebrowser root. Useful for refactoring
  • Snap Open - This plugin makes it much more convenient to open related source files.
  • TODO - find TODO's and such in your code
  • ZenCoding - Sort of like snippets on steroids. Meant for writing html and css very fast
Unpack the files in ~/.gnome2/gedit/plugins then open gedit and enable the plugins you need from Edit > Preferences > Plugins

Many other plugins are available at the official Gedit plugin page.

Customization

Under Edit>Preferences there are numerous other options to customize gedit.

  • line numbers
  • text wrapping
  • current line highlighting
  • bracket matching
  • tab width
  • auto indentation
  • color scheme
etc...

Color Schemes

Good color schemes paired with syntax highlighting make for less eye strain and more productivity. (I think so anyway...) the gedit-bundle includes a few extra dark themes and the gmate-bundle has a plethora to chose from.

for some additional color schemes -- gedit-themes

g:tag helpers

Based on gedit's Tag List plugin. Easily insert grails tag snippets from the side panel. Gedit comes with a handful of useful code tags for things like HTML, but if you want g:tags you need to include some of your own stuff. Place the tags file from the gedit-grails-bundle into /usr/share/gedit-2/taglist/

there is also a bunch of tags for CSS, PHP and HTML in this blog post on using Gedit for web-development

Snippets

Even better than the tag plugin is the snippets plugin. CSS, JS, HTML and JAVA are already supported. A good number of Groovy and Grails snippets are available, and you can easily add your own. Install snippets from the gedit-grails-bundle by putting xml files into ~/.gnome2/gedit/snippets

Screenshots

Credits

This page compiled by Aaron Eischeid but based on work by others:
http://grigio.org/pimp_my_gedit_was_textmate_linux
http://www.sudovi.com/blog/show/teach_gedit_grails
http://www.infosafe.fr
http://groovyandgrails.com/?p=16
http://www.micahcarrick.com/09-29-2007/gedit-html-editor.html
http://blog.tuxcoder.com/2008/02/tweak-gedit-into-programmers-ide.html