Recipe 2.6. Developing Rails in OS X with TextMate


Problem

You use Mac OS X and want a GUI-based text editor that makes Rails development productive and enjoyable.

Solution

TextMate is the GUI text editor of choice for most Rails developers running OS X (http://macromates.com). TextMate is not free software but can easily be paid for with one or two hours of Rails consulting work.

Discussion

TextMate is the editor used by the entire Rails core development team. In fact, it's probably responsible for creating a majority of the Rails code base. TextMate comes with Ruby on Rails syntax highlighting and a large number of macros that let you enter commonly used Rails constructs with just a few keystrokes.

Almost every option in TextMate can be triggered by a combination of keystrokes. This allows you to memorize the actions that you do most often and minimizes the need for mouse movements. Like many native OS X applications, TextMate uses Emacs-style key bindings while editing text. For example, typing Ctrl+A takes you to the beginning of the current line, Ctrl+K deletes from the cursor position to the end of the current line, etc.

TextMate opens a single file with a deceptively simple looking window, but it also has excellent support for projects (directories containing multiple files, subdirectories, etc.) such as Rails projects. Opening a Rails project in TextMate is as simple as dragging the folder and dropping it on the TextMate icon in the dock. Doing so opens TextMate with the project drawer visible. You can explore the files in your project by expanding directories in the project drawer and opening each file into its own tab in the edit window.

Figure 2-2 shows a Rails application in TextMate's project drawer. Also visible is the Go to File window that you open with Option+T. This window lets you switch quickly between files in your project.

Figure 2-2. A Rails project opened in TextMate


TextMate is extendable through built-in or third-party packages called bundles. For example, the Rails bundle adds Rails-specific commands, macros, and snippets that make just about any task in Rails development as easy as typing a keyboard combination. To become more familiar with the options of a TextMate bundle, open and explore the various definitions using the Bundle Editor (BundlesBundle EditorShow Bundle Editor).

See Also

  • TextMate cheatsheet (PDF), http://feldpost.com/lighthaus/textmate_rails.pdf




Rails Cookbook
Rails Cookbook (Cookbooks (OReilly))
ISBN: 0596527314
EAN: 2147483647
Year: 2007
Pages: 250
Authors: Rob Orsini

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net