When I use an EL expression in Eclipse, I naturally begin by typing ${
. Eclipse, wanting to help out a little, places a close brace }
afterward. However, there's a space between them. So if I want ${user.name}
I type ${
, followed by user.name
but my end result is ${user.name }
- that extra space drives me bonkers.
I've looked through all the menus and cannot find where this is defined. Clearly I haven't looked through well enough, because it has to be in there. How can I eliminate... no, eradicate, this space?
My Eclipse info:
Version: Juno Service Release 2
Build id: 20130225-0426
You can disable the auto-close-brace:

Create XML like
<?xml version="1.0" encoding="UTF-8"?>
<profiles version="1">
<profile name="customStyle" version="1">
<setting id="org.eclipse.jdt.core.formatter.yourMatchingConstant" value="do not insert"/>
</profile>
</profiles>
Find your constant in Default code formatter constants of eclipse Replace yourMatchingConstant in above XML file with found.
Then import this XML in Preferences --> Java --> Code Style --> Formatter
Usually this means that the preference to eliminate space when completing the bracket is not provided by the developer of the plugin that validate EL expression.
If it really bothers you to have space by default, there are 2 things you may try to do:
- Make a request on Eclipse's Bugzilla page (since WTP is not a third party plugin). It might be ignored, but worth a shot.
- Make a small tweak on your own: Look for the piece of code that handle the completion of brackets inside the jar, modify it so that it doesn't give space, and then compile and install the modified plugin on your IDE.
The drawback of #2 is that you will need to invest some time to tweak and could not always update WTP to the newest version (since it will override the tweak). But it is feasible.
Probably it's not the best option, but you can create a template like this:

Then, when you need to insert an EL expression, you can press Ctrl+Space, then $ and then enter; and you get an EL expression without spaces and the cursor inside the expression.
You can disable the auto-completion in Web --> JSP Files --> Editor --> Typing. You'll have to type the closing brace yourself, but it is probably better than deleting an errant space.
来源:https://stackoverflow.com/questions/20106819/get-rid-of-that-silly-space-eclipse-generates-when-you-open-an-el-expression