Section 21.6. Integrated Development Environments

21.5. Editor Support

Any modern editor should be programmer-friendly. With memories of the 20th century growing dim, we take it for granted that our editors will reconfigure themselves based on the kind of file we are editing. We expect syntax highlighting, auto-indent, and other such features as a matter of course.

The Ruby coder will not be disappointed by the tools and features out there. Many of these are now standard with an editor's distribution; others are not. Let's take a quick look at what's available.

Two excellent editors are SciTe (based on the Scintilla editing widget) and TextMate (which runs on Mac OS X only). Both are good editors with good Ruby support; I have no further information on them, however.

A third is jEdit, the Java-based programmer's editor ( Its functionality is enhanced by Rob McKinnon's jEdit Ruby Plugin ( I can't cover it further in this book.

The two most common editors in the programmers' world are vi (or vim) and emacs. Let's look at these briefly.

Historically three different packages were available for vim users. Fortunately these are now consolidated into a single package called vim-ruby. This set of config files offers syntax highlighting, auto-indent, and code completion. It also enables such things as invoking the Ruby interpreter from within the editor (compiler plug-ins).

If you are running vim version 7 (as you should be), you probably already have these features installed. (If you're running 6.x for no good reason, upgrading is recommended.)

However, you may find that these features are disabled (probably for backward compatibility). Turn them on by adding the following to your .vimrc file:

set nocompatible syntax on filetype on filetype indent on filetype plugin on

There are also at least two implementations of code folding for Ruby. In my opinion, any folding technique that forces you to put special comments or characters in your code is not optimal. A good code-folding mechanism should be smart enough to look at the syntax of your code and recognize classes, modules, methods, and so on. One good implementation of code folding in vim is by Mauricio Fernandez; find it at

Arguably there are many reasons to dislike vim; one of the greatest reasons is surely vimscript. The good news is it's possible to script vim's behavior using Ruby. The bad news is this is not well documented. If you want to learn about this, I recommend using :help ruby in vim as a starting point. You can also go to for more information. Finally, do a search of http://vim/org to see what recent information you can find.

The other most popular editor in the world is emacs. Actually, to call it an editor is a bit misleading; it is more like a miniature operating system that happens to do text editing on the side. One of the great advantages of emacs is that it is highly extensible; the user can program its behavior in a Lisp variant called elisp. The elisp language is more powerful than vimscript; however, it is just as difficult to read (but in a different way).

I am not an emacs user, though I have great respect for those who are. I can't comment at great length about Ruby support in emacs; I will only refer you to the wiki at RubyGarden (

The Ruby Way(c) Solutions and Techniques in Ruby Programming
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2004
Pages: 269
Authors: Hal Fulton

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: