What Editor Do Rubyists Use?

    Abder-Rahman Ali
    Abder-Rahman Ali

    Well, you’ve decided to learn Ruby, have you? That’s great! Ruby is a wonderful language that aims to make programmers happy. Go for it! As you enter the world of Ruby you realize, “I need an editor”. OK, Google, find me the best Ruby editor.

    Holy smoke! There are a ton of editors, each with a community that swears by its features. “Use vim!” “Use Emacs!” “Use TextMate!” “Use Sublime Text!”. You recoil in fear….what if you make the wrong choice???

    This short story, which likely applied to many Rubyists, inspired me to interview established Rubyists about their best Ruby editor. If nothing else, this will show which editors are used by more Rubyists, with some data as to why. My hope is that it will serve as a guide for newcomers to Ruby, or possibly even those already working with Ruby, on which editors are popular.

    I spoke to 100 Rubyists. The interviews brought up the following editors (given in order of preference):

    1. Vim
    2. Sublime Text
    3. Emacs
    4. Atom
    5. TextMate
    6. Sakura
    7. Pico

    Vim was, by far, the most preferred editor, being utilized by 50% of the interviewees. The charts below tell the tale:

    columnchart piechart

    I spoke to two of the most well-known Rubyists: Yukihiro Matusmoto (Matz) and David Heinemeier Hansson (DHH). If you don’t know, Matz is the creator of Ruby as a language, and DHH is responsble for Ruby on Rails. Matz prefers Emacs, while DHH uses the original version of TextMate. I find it very interesting that two pillars of Ruby don’t use the most popular editor, surely something to consider when choosing your toolset.

    Regardless, Vim wins the Most Used Ruby Editor award for my sample set. Vim was written by Bram Moolenaar, and first released to the public in 1991. There’s no end to the articles about Vim on the web, including two very good ones here on SitePoint. Islam Wazery penned Getting Started with Vim and Effective Rails Development with Vim, both worth reading if you are choosing the beaten path.

    But, what is it that makes Vim so special? Well, the answer is “many, many things”. I will pick a couple of items from an article called Great Vim Features that consists of contributions from many Vim users to try and drive the point home.

    Stephan Houban states that one of the features of Vim he loves is the macro feature. At first glance, this feature may not seem so special. q[letter] starts recording a macro, a second q terminates it. The macro is invoked my typing @[letter].

    But, that’s just when the fun starts. Let’s say I want to create a macro that does the following: Go down one line and replace the first and the second word. Using standard Vim commands, this can be expressed as: j^dwwhp

    Recording this sequence into a macro called @a is done as mentioned previously. Now, you can repeat the macro for all the lines in the file, if you like. Not bad!

    Stephan Thorn comes in and says, “This is nice, but the idiom can be improved immensely using :g.”

    For example, you’ve got a macro for changing the second word on a line to “foo” qb^wcwfoo<esc>q (man, that looks weird to type). Now, visually select a block you want to perform the macro. Don’t yank the selection, though, instead press :, which will place you into command mode for the selected block (the command line looks like :'<,'>, marking the start and end of the visual block). Then, append g/^/normal @b, so the command line looks like:

    :'<,'>g/^/normal @b

    (Note: This presumes the macro you recorded was saved with the letter ‘b’.)

    This will execute the macro for each line in the visual block. Complex to explain, but it’s surprisingly quick once you’re familiar with visual mode and :g/.

    Another contributor in that article compares some features with Emacs:

    “IMHO, the single most useful feature of VI which Emacs does not have (AFAIK) is the . (dot) command, which repeats the previous operation. (i.e.: previous insert, replace word, delete word, …). It makes you appreciate why VI is a modal editor.”

    (It’s worth noting that Emacs users have responded to this claim, which is another reason to read it.)

    Finally, I would like to highlight another comment about someone’s preferred features in Vim:

    I definitely appreciate the following features of vim:

    • unlimited undo
    • editing the history of ex commands (issue some ex commands, press : and use the arrow keys)
    • editing the history of search commands incremental search
    • persistent marks

    While Vim has a commanding lead in numbers, that is but one consideration. Do you have an opinion? Love Vim? Use Sublime Text? What is your best Ruby editor?

    Frequently Asked Questions (FAQs) about Ruby Editors

    What are the key differences between Emacs and Vim as Ruby editors?

    Emacs and Vim are two of the most popular text editors used by Ruby developers. Emacs is known for its extensibility and customizability. It has a built-in Lisp interpreter, which allows users to write their own functions and commands. Vim, on the other hand, is praised for its efficiency and powerful command language. It has a modal interface, which means that it has different modes for inserting text and for navigating through the document. Both editors have a steep learning curve, but once mastered, they can significantly improve your coding efficiency.

    Why does the creator of Ruby on Rails prefer dynamic typing?

    Dynamic typing allows variables to hold any type of value at any time. It provides flexibility and ease of use, which can speed up the development process. The creator of Ruby on Rails, David Heinemeier Hansson, prefers dynamic typing because it allows him to write less code and get more done. It also makes the code easier to read and understand, which is crucial for maintaining large codebases.

    How does the choice of editor affect the productivity of a Ruby developer?

    The choice of editor can significantly affect the productivity of a Ruby developer. A good editor can provide features like syntax highlighting, code completion, and error detection, which can help developers write code more efficiently. It can also provide tools for navigating through the codebase and for debugging. However, the most important factor is personal preference. A developer will be most productive with an editor that they are comfortable with and that fits their workflow.

    What are some other popular editors for Ruby development?

    Besides Emacs and Vim, there are several other popular editors for Ruby development. Sublime Text is a lightweight and fast editor with a clean interface. It has a powerful plugin system, which allows users to extend its functionality. Atom is a modern and feature-rich editor developed by GitHub. It has a built-in package manager, which makes it easy to install and update plugins. Visual Studio Code is another popular choice. It has a robust set of features, including integrated Git support and a built-in terminal.

    How can I choose the best editor for my Ruby development needs?

    Choosing the best editor for your Ruby development needs depends on several factors. You should consider the features of the editor, such as syntax highlighting, code completion, and error detection. You should also consider the learning curve of the editor. Some editors, like Emacs and Vim, have a steep learning curve, but they can be very powerful once mastered. Finally, you should consider your personal preference. You will be most productive with an editor that you enjoy using and that fits your workflow.