Linux: Making yourself a nice editor

You may have noticed that configuring your Linux system is largely a matter of editing various (plain text) files. The RedHat package contains configuration tools that provide an alternative way of doing this, but all the same you'll probably want to edit text files quite a lot, as you get to know the capabilities of your system.

To make life easier you'll want an editor that you're comfortable with, and for people coming to Linux from Windows I strongly recommend NEdit (free software from the folks at Fermi Lab): you'll find that most commands are where you expect them to be, the mouse does what you'd expect it to do, and so on (which is not always the case with more ``hard core'' unix-style editors such as emacs or vi). In addition it has many powerful features that you can discover (or not, as you please) over time.

Now, all X GUI programs (such as NEdit) rely upon some ``library'' of shared code (or ``widget set'') for their basic graphical elements (menus, dialog boxes, etc.). There are many such widget sets for X. NEdit uses the popular Motif libraries, which produce quite a pleasing appearance - but Motif is a commercial product, and quite expensive. Is this a problem? Not really, since an excellent open source clone of Motif is available, called Lesstif.

So here's the plan: If you follow the steps here you will

(Caveat: I don't know the RedHat CDROM, but it's quite likely that there are rpm's - RedHat pre-made packages - for Lesstif and/or NEdit on the CD, in which case you don't have to do this the ``hard way'' that I'm describing. But you'll learn more this way. And it's not really hard. Your choice.)

Developer tools

Still with me? Good. Then first check your prerequisites. Did you install the ``developer'' series of packages from the RedHat distro? You'll need those, to compile stuff. It's not the case that only people who are actually developing code need the ``developer'' tools; they are needed by anyone who is going to compile source code - and that is just about anyone who's running Linux and who has a modicum of intellectual curiosity. I think the Linux distributions could make this clearer to new users.

If you plan to follow through, it may not be a bad idea to print out this tutorial now.

Download and build Lesstif

Note: You need to be root in order to install software in ``public places'' on your system, as described below. Also note that ``[KEY]'' means press the key marked ``KEY'' - e.g. ``[Tab]'' means press the Tab key.

Now get on the net and point your browser at the Lesstif site. If you want to read about the Lesstif project, see their news and so on, go in the front door at www.lesstif.org. If you'd rather cut to the chase, go straight to the download area at ftp.hungry.com. Look for the latest stable release - as of this writing it was lesstif-0.88.9.tar.gz. You want to save this ``tarball'' to your hard drive. I suggest putting it in /usr/src, a common location for source code packages. (The Lesstif source package is 3133 Kb, but don't despair - if you have a 28.8kbps modem or better it won't take forever to download.)

Now get to the command prompt in an xterm, and issue this sequence of commands:

If all has gone well, you may now clean up. Assuming you have no further use for the Lesstif source code, do

Download and build NEdit

All right, now let's put those Lesstif libs to work.

Point your browser at the NEdit site. The front door is at fnpspa.fnal.gov; the download area at ftp.fnal.gov. The current version is 5.0.2. From the ftp site get the source code tarball, nedit_source.tar.gz (511 Kb).

Again, save this to /usr/src, and, at the command prompt in that directory, do:

ls
tar tvfz ned[Tab] | less

Comment: Let's just take a look inside (``t'' flag instead of ``x'' for tar) this tarball (piping the listing into the pager, less) first. Aha, the files are not all packed into one top-level directory, as with lesstif. Type ``q'' to quit less. If we explode the tarball in /usr/src it will be a bit awkward keeping track of all the files. OK, we'll make a directory for it, move the tarball in there, and work there.

mkdir nedit
mv nedit_[Tab] nedit
cd nedit
tar xvfz n[Tab]
ls

This time we've got a README and a Makefile, but no ``configure'' script. OK, let's take a look at README. Hmmm, seems like all we have to do is

make linux_nedit

The NEdit build takes about 5 minutes on a P133. See the little ``-lXm'' on the third last line of the screen output from the make command? That says that nedit has successfully linked with your new Motif (well, Lesstif) library. That was pretty painless.

Now, can we do ``make install''? Oh, ``No rule to make target `install' ''. Well, we'll have to put it in place manually. We remember that the README told us the binaries (executable files) would be in the ``source'' sub-directory. So

cd source
ls
install -s nedit /usr/local/bin
Comment: The ``install'' program will put nedit into /usr/local/bin, a reasonable place for ``home-made'' binaries. The ``-s'' flag means that install will strip the program first, making it a bit smaller.

install -s nc /usr/local/bin
Comment: Likewise the NEdit client program (you may not need this.)

Now what about documentation? We'll want to ensure that the manual pages are available. Weren't there some ``.man'' files back in our top-level nedit directory?

cd ..
ls

Comment: Yes. Now let's put them in a suitable place. Corresponding to /usr/local/bin for local binaries is /usr/local/man for manpages. Pages for ordinary user programs generally go in man1, and are given a ``.1'' extension. So:

cp nedit.man /usr/local/man/man1/nedit.1
cp nc.man /usr/local/man/man1/nc.1

...and check them out:

man nedit
man nc

Brilliant. Let's also take a peek at nedit.doc. Ah, it seems to be a basic explanation of using the program, somewhat fuller than the manpage. Where might it go? On many Linux systems /usr/doc is the appropriate place. OK, so

mkdir /usr/doc/nedit
cp nedit.doc [Esc].

Comment: Eh? Well, in the bash shell, ``[Esc].'' pops onto the current command line the last term from the previous command line. In this case we just made a certain directory, and then immediately wanted to copy a file into it. So [Esc]. is our friend. And while we're at it

cp README [Esc].

Now clean up again:

cd ..
rm -rf nedit

Check out your new editor by typing ``nedit'' at the command prompt in an xterm, or ``nedit filename'' to open an existing file. You may want to type an ampersand after such commands for launching GUI programs: ``nedit &''. The ampersand ``backgrounds'' the job, or in other words gives you back the command prompt right away (otherwise the command prompt is ``frozen'' until you exit the GUI program).

If NEdit doesn't come up for you, try typing the full path to the binary:

/usr/local/bin/nedit

If that works, we infer that the program is OK but /usr/local/bin is not included in your PATH. You can fix this temporarily by typing

export PATH=$PATH:/usr/local/bin

You can fix it permanently by putting this line into the file .bashrc in your home directory.

You'll probably want to add NEdit to the menus in your X window setup. If you're using the default RedHat window manager, copy the text below into an editor (e.g. NEdit!), replace ``Group'' with the name of the menu in which you want NEdit to appear, and save the file as /etc/X11/wmconfig/nedit

nedit name "NEdit"
nedit description "GUI Editor"
nedit group Group
nedit exec "/usr/local/bin/nedit &"


Allin Cottrell (cottrell@ricardo.ecn.wfu.edu), November 8, 1998.