Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

August 29, 2006

Develop Ruby Applications Using SciTE Editor

Filed under: GNU/Linux, Ruby/Rails — tabrez @ 10:15 pm

In the first and second parts of the series “Popular IDEs For Ruby Development”, I have mentioned two of the excellent IDEs available for developing Ruby applications:

1. Ruby Development With Eclipse IDE
2. Ruby Development With Komodo IDE

Though these IDEs boast of a large number of useful features to help developers achieve higher productivity levels, some people might find the very same features to be needless quirks that come in the way of the software development. For all the programmers who swear by the rich functionality provided by an IDE like Eclipse, an equal number of programmers feel more comfortable and more productive with simple but elegant, fast to load editors like Emacs and Vi. One such popular editor which has got inbuilt support for the Ruby programming language is SciTE. I will discuss Ruby program development with the SciTE editor in this post; Ruby development with Emacs and Vim will be the topic of the next post in this series.

SciTE is actually one of my favourite editors to develop Ruby programs. The reasons are very basic: it’s light-weight, it’s fast, it has out-of the box support for the Ruby language(no plugins as in Eclipse or editing modes as in Emacs are needed to be installed) and it runs on multiple platforms including Windows and GNU/Linux. It also has got excellent support for the other programming languages(more than 40!) like C/C++, Java, Perl, Python and PHP. And of course its free in every sense of the word.

Open the SciTE editor from the system menu or from the command line, create a new file and save the file with .rb extension; the editor will automatically switch to the Ruby mode and will do the appropriate syntax highlighting for the code. The Ruby language can also be explicitly selected for the program currently being edited, by selecting Language->Ruby menu item.
Ruby Program in SciTE

Once the editing is complete, the Ruby program can be executed by selecting the menu item Tools -> Go or by pressing the F5 key.
Rub Ruby programs from within SciTE editor

A new pane will be opened on the right side of the window to run the script and it will show if any errors are present in the program, or the output of the program otherwise.
SciTE shows any errors in the Ruby programs

Once all the errors in the program are fixed, pressing the F5 key will show the output of the program in the right pane.
Ruby program output in SciTE editor

With fast load times, support for syntax highlighting and code indentation, ruby interpreter and ruby interactive shell being supported from within the editor, SciTE provides an excellent environment for Ruby application development. It doesn’t end here though; SciTE also allows a lot of customisations to be done to the programming environment according to the tastes of the programmers. To affect the global settings of the editor that apply to the settings of all the programming languages(not just Ruby), select Options -> Open Global Options File menu item.
Global Settings in SciTE

As an example, scroll down to around line 100(View -> Line Numbers to view the line numbers) and search for a property called “tabsize” and change it to 4(or whatever you prefer). Or scroll down roughly to the line number 300 and increase/decrease the font size by editing font.base property(under your platform):
Change font properties in SciTE global settings

Settings specific to the Ruby mode can be customised by going to Options -> Edit Properties -> Open ruby.properties.
Ruby settings in SciTE

You will see a similar list of properties that were present in the global properties file and the values of specific properties can be edited in the same way.
Change properties in SciTE Ruby settings

Ruby interactive shell can also be used from within the SciTE editor to test simple Ruby expression before using them in the programs. Just place the cursor in the right pane(output window; go to View -> Output if it is already not visible), type the command ‘irb’ and press the ENTER key. You will be dropped to an irb shell where you can experiment with various Ruby expressions.

I prefer to work with the SciTE editor(not just for Ruby) for various reasons pointed out earlier in this post. Most important of them all are that its available for both Windows and GNU/Linux(it looks and works the same way in both these OSes) and it supports most of the programming languages that I use. If you open a lot of different files for editing during one marathon editing session, you can save the state for later retrieval by saving and loading the sessions. The program files can also be exported to different document formats like PDF, RTF, HTML etc(from File -> Export menu). If you are searching for a light-weight, fast, multi-platform programming editor, then SciTE will be a great option to consider.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Programming in Ruby Using SciTE - Windows Issues and Other Tips
  • Develop Ruby Applications Using JEdit Editor
  • Installing Ruby on GNU/Linux(Gentoo, (K)Ubuntu, Fedora, SUSE) And MS Windows
  • Develop Ruby Applications Using Komodo IDE
  • Develop Ruby Applications Using Eclipse IDE
  • Develop Ruby Applications Using Vim 7.0 Editor
  • Setting Up Rails Development Environment on Windows Vista/XP

  • 8 Comments »

    1. I am having few problems with SciTE (version 1.67).
      - irb command is not recognized in the ouptut winodw
      - can’ type anything in the DOS command window when it is opened via gets.
      Any help?
      Thanks, Mihail

      Quote

      Comment by mihail — October 20, 2006 @ 1:40 am

    2. Are you using SciTE under GNU/Linux or Windows?
      Follow these steps:
      Start the SciTE editor; go to View -> Output; in the output window, type the command ‘ri Kernel#gets’ and see what result it generates. What happens when you type the ‘irb’ command?

      Quote

      Comment by tabrez — October 20, 2006 @ 12:17 pm

    3. For both - “the system cannot find the file specified”.
      When run them in a DOS Command Prompt both work - the path is set right.
      I am confused…

      Quote

      Comment by mihail — October 23, 2006 @ 11:04 pm

    4. i am having problems creating a program to remember what has been typed? it is basically creating your own “key logger,” any suggestions?

      Quote

      Comment by moe — November 25, 2006 @ 2:55 am

    5. I think you may need to type irb.bat in the command window in you are running scite on windows

      Quote

      Comment by Guillermo — July 4, 2007 @ 3:54 pm

    6. I have the same problem as Mihail,

      To reiterate:
      - irb command is not recognized in the ouptut winodw
      - can’ type anything in the DOS command window when it is opened via gets.

      I’m using Vista. I basically have to open the command prompt and run my programs from there when using Ruby.

      Quote

      Comment by Jonathan — October 11, 2007 @ 8:07 am

    7. Mihail, Jonathan:

      1. If you are using SciTE on Windows, try specifying the full name of the ruby commands in the output window:
        irb.bat
        ri.bat IO#read

        Or you can create shortcuts to these commands. If you use these commands frequently, you can also create a menu item for them in “Tools” menu by adding the following lines to the Ruby properties file(Windows section only):

        command.name.0.*.rb=irb
        command.0.*.rb=irb.bat
        command.is.filter.0.*.rb=1
        command.0.subsystem.*.rb=1

        You can now invoke irb from Tools -> irb or by pressing Ctrl-0 key combination. (Use another number instead of 0 if you have already bound Ctrl-0 to something else.)
        To know more about what the above properties mean, refer to SciTE documentation from Help -> SciTE Help menu item.

      2. Regarding the second issue, you are not supposed to enter anything in the DOS command window, just minimize it whenever it opens and continue to work with the SciTE editor i.e. enter your input for the gets method in the _output window_ within the SciTE editor.

      Let me know how it goes. I will probably make a separate post to talk about the issues specific to Windows.

      Quote

      Comment by tabrez — October 12, 2007 @ 6:23 pm

    8. [...] of comments(by Mihail and Jonathan) on my earlier post about programming in Ruby using SciTE editor brought this to my notice: When using SciTE to develop Ruby programs on Windows platform, there are [...]

      Quote

      Pingback by Programming in Ruby Using SciTE - Windows Issues and Other Tips — October 14, 2007 @ 4:07 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost