Open Source Software Technical Articles

Want the Best of the Wazi Blogs Delivered Directly to your Inbox?

Subscribe to Wazi by Email

Your email:

Connect with Us!

Current Articles | RSS Feed RSS Feed

jEdit: The Force is Strong with This Programmer's Editor


In a recent article I referred to the holy wars in the Linux world without mentioning one of the most common: your preferred text editor. Different people swear by tools such as Vim, Emacs, XEmacs, or gEdit. Even so, if you ever work on developing program code, you should find a lot to like in jEdit, a programmer's editor that offers a nice combination of simplicity, speed, and features.

The best editor for any particular task is whichever gives you the right tools for the job. jEdit's design allows you to use it as a simple editor, but also use it as an IDE and expand its functionality via plugins so that it becomes exactly what you want it to be for the task or language at hand. jEdit is not, however, an IDE with everything but the Christmas tree, like Eclipse or Microsoft Visual Studio. Rather, it's a compact application for editing code, providing practical tools along with basic IDE features.

Because it's Java-based, you can install jEdit on any platform that supports Java, including Linux, BSD, Solaris, or Mac OS X. Make sure that you have Java 1.6 or newer installed before you install jEdit; refer to your operating system's documentation for instruction on setting up Java on your machine. jEdit's homepage provides links to resources that allow you to get started quickly, including Windows and Mac OS X installers, packages or repository definitions for some Linux distributions, source code, a system-neutral installer, and instructions.

FreeBSD and Gentoo users already have jEdit in their official repositories. If you can, install a binary package from a repository if one is available. I'm running Fedora, and when I tried installing jEdit from the repository I got lots of "404 - Not Found" errors before yum exited. So I just downloaded the platform-independent installer, changed to that directory, and ran $ java -jar jedit4.4.2install.jar. The installer allows you to choose the destination directory of the binary and the manual page, then proceeds with the installation. I installed jEdit in my home directory, so it would be available only to me, and since Fedora adds /home/username/bin and /home/username/man to PATH and MANPATH, I didn't have to do anything else. Not all distributions do that, though, so alter those two environment variables if you need to. If you want to make jEdit available to all users, run the installer as root and choose a system-wide location such as /usr/local/ or /opt.

Using jEdit

I started using jEdit on some C code.

Almost every jEdit menu and submenu has a keyboard equivalent. The style reminded me of Emacs key bindings, only more accessible. If you can get used to using keyboard shortcuts, you can become more efficient. The Edit menu shows all the tools you need to manipulate text and code, including not just the usual copy/cut/paste commands, but also a clipboard manager, a selection manager, and tools for indentation and highlighting. The Folding menu resembles the KDE-centric editors, as it helps you isolate code blocks, collapse and expand them, and go to parent. I tested this feature only with C and Java code, where code blocks are delimited by braces, but it should work with any structured code. Like other editors, jEdit deals with buffers, so you can open different files in multiple buffers, cycle through them, and use split views.

Syntax highlighting works as you'd expect, meaning it offers nice colors and functionality for more languages than one probably can remember first-hand.

I got a pleasant surprise when I opened jEdit's Plugin Manager (Plugins -> Plugin Manager), because of the richness of functionality offered by the available plugins. Some of the plugins I recommend if you write C code include Cscope Finder, CtagsInterface, and GdbPlugin. For networked, interactive development I suggest FTP, BzrPlugin, and GitPlugin, or one of the plugins for the version control system (VCS) you use. Thanks to the Console plugin, you can either change to the current directory and run gcc or llvm or your compiler of choice, or you can use one of the commands any C/C++ IDE would offer, such as build, run, or open a gdb console. For writing all kinds of code (not just C), plugins such as Beauty help programmers make code more aesthetic and understandable, while the SideKick plugin helps for browsing code.

The Code2HTML plugin helps when it comes to writing developer documentation. Here's an example of what it produced from some Java code in the jEdit source tree:

24 /**
25 * A read-only text segment from a buffer. Allows concatenation using a
26 * "linked list" approach.
27 *
28 * @author Marcelo Vanzin
29 * @version $Id: 12726 2008-05-29 20:21:14Z k_satoda $
30 * @since jEdit 4.3pre15
31 */
32 class BufferSegment implements CharSequence
33 {
35 public BufferSegment(char[] data,
36 int offset,
37 int len)
38 {
39 this(data,offset,len,null);
40 }

Documentation always looks nicer when the code is properly indented and highlighted. This plugin works as long as jEdit can recognize the language you're using and can perform syntax highlighting. Speaking of which, jEdit's website says the editor supports more than 130 languages when it comes to auto-indent and highlighting. To check this out for yourself, press Ctrl+Shift+n (new file in mode), where mode is a specific way to treat a text file depending on the language it is written in, offering adequate indentation and syntax highlighting on the fly. In addition to popular languages and tools like C/C++, Java, PHP, Perl, ColdFusion, and Django, you'll see some highly specialized ones, like Verilog and Transact-SQL.


Configuring jEdit

All of the foregoing jEdit can do without customization, but the editor also provides a number of knobs you can turn to make it work as you want it to. You can access the customization menu by pressing Ctrl+F12 or going to Utilities -> Global Options.

I could probably write an entire article about jEdit's options. You can change to your liking possibly everything that's customizable in a text editor, be it abbreviations, mouse behavior, or the viewing layout. One feature I love is the option to customize the context menu you get when you right-click on a particular segment of the jEdit window. You can choose options that control the default edit mode (text or xml or assembler or ...), tab stop and indent width, the Gutter (no, it's not a rock band, it's the component that deals with syntax highlighting), printing, keyboard shortcuts (all commands can have a shortcut), encodings or the toolbar's structure.

jEdit allows you to be in control of your work environment so you can become more efficient. It can improve your workflow with its custom keyboard shortcuts, the ability to have individual settings for each editing mode, and the flexibility of its user interface. Like every new tool, it takes some time to get used to, but jEdit makes it worth it your while.

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.


Currently, there are no comments. Be the first to post one!
Post Comment
Website (optional)

Allowed tags: <a> link, <b> bold, <i> italics