Wednesday, May 20, 2009

Using jEdit as an external editor for Eclipse

Here is a tip on how to use jEdit as an external editor from Eclipse. What this means is that when you open a file for editing in Eclipse, Eclipse will open jEdit and the editing happens in jEdit rather than in Eclipse. This is great since jEdit is a better editor than Eclipse is, and in some ways, Eclipse is a better IDE than jEdit is.

First, I created a small shell script and put it in my path:


java -jar /home/danson/apps/jedit/jedit.jar -reuseview $1

You'll want to adjust the path as appropriate for your system. Windows users should be able to create a batch file to do exactly the same thing. I have a "bin" directory in my home folder that is in my path, so I put the shell script there. The "-reuseview" parameter is important so you only get one jEdit window. Without this parameter, you'll get a new jEdit window per file.

Next, tell Eclipse to use jEdit:

  1. Go to Window, Preferences, then General - Editors - File Associations.
  2. Select the file type you want to be able to edit in jEdit.
  3. Click the "Add" button beside the "Associated editors" box.
  4. Select "External programs", then "Browse", then pick your shell script from the file browser and click "OK".
  5. See that jEdit shows up in the associated editors box. You can choose it and set it as default.

It would be nice if Eclipse allowed picking multiple file types at once so it would be easier to associate say, java, jsp, js, and html files all at once to jEdit.

Now when you open a file of that type, Eclipse will open jEdit as the editor. You can still open the file in Eclipse if you'd like, just right click on the file in the perspective, choose "Open with", and pick what you want.

No comments: