April 10th 2009

Ruby, Rails, RHTML and Shoulda Snippets for gedit

Gedit is the built-in text editor of Gnome. It is really straight-forward and no-bs, so it is my favorite environment for coding, since I prefer things to be really snappy rather than standing in my way.

It has a built-in snippets plugin which allows for easy expanding of your predefined shortcuts into the actual method name by hitting TAB - very much like TextMate or plenty of other editors that have such a feature. The snippets for Ruby supplied by default are pretty sloppy and incomplete though, so I've built my own.

They feature not only the default Ruby def, class, if (...) statements, vastly improved compared to the original ones supplied with gedit, but also ActiveRecord validations, associations, ActionController before filters, ERB, and Shoulda macros. For example, sstft will expand to should_set_the_flash_to :(cursor_position).

Please check the command cheatsheet on the corresponding github page and have a look at the documentation in the Readme supplied in the Github repository for instructions on how to install them, which basically are two shell commands

If you need to set up mime-types and syntax highlighting for Ruby and friends, please also check out these two articles, which are a tad dated but still should lead to a working setup for your coding galore:

In the Readme on Github, I also supplied a couple of rules that I am trying to stick to when writing new snippets. Feel free to fork the repository, add Snippets and send me a pull request! And to make things even fancier, here is a sweet little video demonstration of some of the snippets:
Written by Christoph Olszowka
blog comments powered by Disqus