Get rid of that silly space eclipse generates when you open an EL expression
Asked Answered
D

5

9

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
Doura answered 20/11, 2013 at 20:55 Comment(3)
This problem doesn't happen in Kepler. You could just upgrade to Kepler.Ply
@iRuth Running Kepler, it still does it. If I type ${ I get ${ } with my cursor after the {. :-(Doura
Man, that's a big bounty on something that probably doesn't have the answer you want. This is something so tiny, I suspect it's not configurable, and the solution is to fix it in the code. Or accept any of the many workarounds that are probably just as bad as the space itself.Permute
D
3

You can disable the auto-close-brace:

enter image description here

Drunken answered 28/11, 2013 at 5:31 Comment(1)
Yes, as noted in my self-answer, I can do this, and it is better than nothing. It's still not full of awesome like getting rid of the space.Doura
A
3

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

Adamic answered 28/11, 2013 at 10:58 Comment(3)
I think this is on the right track, but unfortunately that particular set of constants is for Java code. I'm trying to manipulate JSP code.Doura
Bad luck then. Untill eclipse provide something for jsp let this space drive you bonkers :DAdamic
Well, none of the answers are really what I'm looking for. But if I don't award the bounty, it gets lost anyway. I think yours was the most creative, and I learned something about the formatter constants too. So even though it didn't solve it, it still helped me the most, so I'm going to award it to you. However, since it doesn't actually solve the problem, I can't accept the answer. Sorry...Doura
D
2

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:

  1. Make a request on Eclipse's Bugzilla page (since WTP is not a third party plugin). It might be ignored, but worth a shot.
  2. 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.

Dump answered 27/11, 2013 at 13:42 Comment(0)
R
1

Probably it's not the best option, but you can create a template like this:

enter image description here

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.

Rogers answered 3/12, 2013 at 9:28 Comment(0)
D
0

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.

Doura answered 27/11, 2013 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.