jEdit in Mac OS X and the Alt/Option key

jEdit is one of the best cross-platform text editors out there (note the difference: it's just a text editor, not a word processor!) and certainly the choice of editor for many programmers. It's written in Java, so you can run it pretty much on all sorts of OSes (Windows, Mac, various Linux distros, OS/2, VMS ... just to name a few that it was already tested with). However on Mac OS X you'll run into the Alt/Option key problem pretty soon. By default the Mac version does not recognize Alt for use in shortcuts, which pretty much crapples the whole thing. Of course, there's an easy solution.

A generic Google search did not give me the hits I was looking for, but restricting the search to the site I found the answer instantly. You'll have to go inside the application folder of jEdit (you know: right click the jEdit application in Finder and hit "Show package contents"), go to the
Contents/Resources/Java/startup folder and you'll hopefully find a startup.bsh script in there. Copy this script to your settings folder ($HOME/.jedit/startup) and uncomment this part:
/* ... and this the MacOS default: */
        InputEvent.META_MASK,  /* == C+ */
        InputEvent.CTRL_MASK,  /* == A+ */
        InputEvent.ALT_MASK,   /* == M+ */
        InputEvent.SHIFT_MASK  /* == S+ */

and the following two lines:

Now restart jEdit and you should be able to specify shortcuts with Alt/Option in them. You can test various shortcuts with the Keyboard Tester (you find it in the "Utilities/Troubleshooting" menu.

properties11.19 KB
startup.bsh2.37 KB
jedit_keyboard_tester_output.jpg220.98 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

You just saved me a lot of

You just saved me a lot of trouble (either searching for the same solution or abandoning jEdit because of this). Thank you for taking the time to write this!

Re: You just save me

Thanks for the feedback. It's good to see from time to time that my efforts to share some knowledge here are not in vain.

Option key is *sort of* fixed, but some characters still fail

Using the instructions here, I found that I could remap most keys, like M-1 (option-1) and M-3 (option-3), but some not-too-weird characters like ™ (TM) and ∆ (delta) still took precedence over the meta signal.

In other words, option-2 generates a ™ (TM) symbol, and looking at the keyboard troubleshooter, it actually generates a specific ASCII value *without* the Meta modifier being set at all!

I wonder if there is any way to fix this? I would like to remap, say, "option 2" to "split window horizontally" like I have it in emacs, but I can't figure out if that is possible.

It's weird, because option-3 of course can be remapped with no trouble.

Nice post - doesn't work for me though

I'm running OS X 10.5.2 and Jedit 4.3pre13 with JVM 1.5.0_13.

I copied the file and made the changes as you suggested, yet I still can't use short cuts that use the alt/option key.

The Keyboard tester allows me to input shortcuts that use alt/option... But jedit still doesn't seem to recognize them

The shortcut I use the most is the change indent level (Alt+Right or Alt+Left)...

Re: Nice post - doesn't work for me though

I'm running OS X 10.5.2 and Jedit 4.3pre13 with JVM 1.5.0_13.
I'm using the same. I've attached my properties and startup.bsh files to this post (they are in the HOME directory of the Mac at /Users/<username>/.jedit and /Users/<username>/.jedit/startup respectively), you might want to compare these with yours.

Thanks for providing your

Thanks for providing your properties and startup.bsh files... I put both of them in place instead of mine, and the shortcuts still aren't working.

Perhaps I have some OS level shortcut that is preventing it from working... Oh well.

Note that on Snow Leopard,

Note that on Snow Leopard, the startup folder is in a different place. On my computer it is at /Users/jon/Library/jEdit/startup.

Re: Nice post - doesn't work for me though

The Keyboard tester allows me to input shortcuts that use alt/option... But jedit still doesn't seem to recognize them.

I've attached a screenshot of my Keyboard Tester output for Alt+Left and Alt+Right shortcuts. Is this what you see if you try to input these shortcuts into your Keyboard Tester? Before the startup.bsh modifications the "Specify Shortcut" window did not show me anything, when I pressed a shortcut involving the Alt key, however the keycodes were output into the opened document ("Untitled-1" as seen on my screenshot). After the modifications in startup.bsh the "Specify Shortcut" window started to show me the names of the shortcuts, even the ones with an Alt key in them (the "M" stands for the Alt key in my screenshot example).

Do you see the names of Alt/Option shortcuts appear in the "Specify Shortcut" window of Keyboard Tester? If yes, then I've got no clue. If no, then it'd probably mean that jEdit does not parse your startup.bsh for some reason.

Ah ha! So, I finally

Ah ha!

So, I finally figured out what was happening. The default keybindings ignore the 'Alt/Option' key. Additionally, the lines in startup.bsh that are commented out and say they are for MacOS says to map the 'Alt/Option' key to a Meta key. However, there are no shortcuts defined as Meta-(keystroke).

If the Alt/Option key sends 'Meta', then the key is useless - as there are no defaults specified that use 'Meta', there are only 'Control', 'Alt', and some 'Shift' ones.

What I did was this:


That way, the command key becomes the Control Key, and the 'Alt/Option' key sends Alt.

Thanks for your help!

Re: Ah ha!

The default keybindings ignore the 'Alt/Option' key.

Yes, they do. I was not aware that you expected the startup.bsh changes to activate the "A+" shortcuts just by themselves. Those changes do no such thing since they map the Alt key to "M+". I've manually configured all my shortcuts that I use regularily and made some shortcuts to use "M+" (which became the Alt key due to startup.bsh). By default no shortcuts take use of "M+" so enabling the Alt key for it won't make a difference in itself.

That way, the command key becomes the Control Key, and the 'Alt/Option' key sends Alt.

Mapping the Alt key to "A+" is a good solution too. This way a lot of the default jEdit shortcuts will be available through the Alt key.

I'm happy you could make it work for you and maybe our discussion will help others too to understand how the Alt, Meta, Control and Shift mappings work.

As I would like to use some

As I would like to use some Alt shortcuts to go to next/previous words, I have uncommented the lines above as you describe. I am able to assign shortcuts to the Alt key and everything works fine. Except that some other "shortcuts" have stopped to function. I use a danish keyboard layout, and normally the combination Alt+Shift+7 gives me a backslash char but after making the changes it gives me nothing! Using the troubleshooting function I get this when I hit Alt+Shift+7:

Event KEY_PRESSED,keyCode=0x9d,keyChar=0xffff,modifiers=0x4,consumed=0 filtered
Event KEY_PRESSED,keyCode=0x10,keyChar=0xffff,modifiers=0x5,consumed=0 filtered
Event KEY_PRESSED,keyCode=0x37,keyChar=0x37,modifiers=0x5,consumed=0 passed
==> Translated to CS<0,37>
Event KEY_TYPED,keyCode=0x0,keyChar=0x37,modifiers=0x5,consumed=0 filtered
Event KEY_RELEASED,keyCode=0x37,keyChar=0x37,modifiers=0x5,consumed=0 passed
Event KEY_RELEASED,keyCode=0x10,keyChar=0xffff,modifiers=0x4,consumed=0 filtered
Event KEY_RELEASED,keyCode=0x9d,keyChar=0xffff,modifiers=0x0,consumed=0 filtered

What does it mean and can you help me get my backslash back?

Syndicate content