Wednesday, October 6, 2010

Unix Text editor with Syntax highlighting

If you work on Unix, chances are the only editor you have is VI. While I am all for proving my manliness by working with VI, I would rather make my life easier. So I did a little bit of research and found a way to install an editor with GUI and syntax highlighting on AIX.
I found that there are two ways to do this. One download source code of any of the linux editors like gedit or VIM and compile on AIX and use them. I am no c/ c++ developer but I have tried to compile VIM 7.3 on AIX 6.1 without success. Second method is to use precompiled java based source editors. After trying JEdit, Jext and RText, I have settled on RText as the best option. JEdit does not seem to work well over putty. Jext does not have syntax highlighting for korn shell scripts so it does not serve my purpose. Otherwise Jext is a good option as well. In the rest of the post I will try and list the steps one would need to follow to get RText working over putty on AIX.

RText is a source code editor with syntax highlighting. 

Softwares you will need:


Prerequisites:

            We assume that you have either Sun’s or IBM’s jre up and running. The installation procedure for jre is out of scope for this post.

Installing Putty
Xming ships with putty. If don't have putty installed already then it is better to install it along with  Xming.
Installing XMing
Xming installation is straight forward. Make sure that the putty checkbox is checked and accept the defaults for the rest of the screens.

Installing Rtext:
  • Download RText
  • Move the file to AIX box if you have not downloaded it to AIX directly. I have myinstallation in $HOME directory.
  • Unzip the file.

         tar  –xvf r text***.tar.gz
  • Copy the following lines into a file named rtext (or anything else you please)

#!/bin/sh
export JAVA_HOME=/usr/java5
export RTEXT_HOME=RText installation directory
export PATH=$PATH:$RTEXT_HOME
$JAVA_HOME/jre/bin/java -jar $RTEXT_HOME/RText.jar
  • Place the file in rtext installation directory (ex: $HOME/rtext/)
  • Rtext Installation complete.
Running Rtext:
  • Make sure if the Xming server is started. If not start Xming from All Programs Menu.
  • Now Fire up putty
  • Click on session in the left side explorer and enter your IP address.
  • Expand SSH and select on X11 in the side explorer.
  • Select Enable X11 forwarding check box.

  • Press Open and enter your user name and password.
  • Navigate to RTEXT_HOME and run rtext. (make sure you have executable permissions on the file.)

  • If you want to be able call rtext from anywhere on the Unix box with just “rtext” command, create a symbolic link for it.
  • ln –s $RTEXT_HOME /usr/bin/rtext
  • If you want to start rtext in the background so that you can run other commands on the putty session use the following command. 
$RTEXT_HOME/rtext &
  • Two things to remember before you attempt to start RTEXT are
    • Check if Xming is started. If the server is started you will see a tray icon. If not start it.
    • Check if your putty session has X11 enabled. Unfortunately if you have not enabled while starting the session the only way to enable it to start another putty session with X11 enabled this time.
Benefits of RTEXT:
  • Has syntax highlighting for sh, ksh, csh.
  • The entire application can be run via one jar unlike JEdit. So the application can be run by issuing 
java –jar Rtext.jar

On a final note, if anybody was successful in compiling VIM on AIX 6.1 I request you to share the procedure with me.