30

I'm trying to disable the automatic closing of brackets in Eclipse, and while I've mostly succeeded, I can't stop the editor from inserting a closing parenthesis for a method call. The result is that when I type:

myBool.equals(true);

it inserts a closing parenthesis as soon as I type the opening parenthesis, and what I actually get is:

myBool.equals(true);)

I've disabled all of the auto-complete options in the Preferences -> Java -> Editor -> Typing menu, as well as Preferences -> Java -> Editor -> Content Assist -> Fill method arguments and show guessed arguments. I also disabled the smart insert mode option under the Edit menu. Is there another option somewhere else I need to use to stop Eclipse from doing this?

This is with Eclipse 3.5.2 (Build ID M20100211-1343) in case it matters.

Edited to add: I should also mention that this only happens if I wait for the "intellisense" pop-up with suggested method names to appear after I type the period. If I just continuously type the code without waiting for the suggestion box to appear, the closing parenthesis doesn't get inserted.

Chris Vig
  • 8,552
  • 2
  • 27
  • 35

3 Answers3

14

I don't know how to disable the method parenthesis auto-complete - so I'm not sure, if you'll be satisfied with my answer. But to avoid ending up with

myBool.equals(true);)

you can actually enable (Parenthesis, [square] and <angle> brackets in the Preferences -> Java -> Editor -> Typing menu. This inserts the parenthesis automatically (which you probably don't want), but you can just continue typing normally, as you would in an editor without "intelligence": Your closing parenthesis will simply overwrite the automatically inserted parenthesis, so you won't end up with );).

Chris Lercher
  • 37,264
  • 20
  • 99
  • 131
  • 3
    That does the trick - I would still prefer to just turn it off completely but I guess this is the best option for now. Thanks! – Chris Vig May 16 '10 at 22:15
  • 3
    I never understood why anyone would want that stuff auto completed... somehow you have to get to the end of the line to enter ; or to hit enter to do the next line. do they expect you to pick up a mouse or arrow over? lols. – JDPeckham Nov 03 '11 at 21:41
  • Still doesn't do the trick if you add spaces inside the brackets to the style (i.e. `foo( vars )`) — if you type the space you expect, you get an extra one. Also a doesn't work with multiple arguments. – dhardy Nov 14 '11 at 20:37
  • 3
    @Chris that doesn't do the trick. That's a hack. Damn eclipse. we **need it fixed**. – Pacerier Nov 24 '11 at 20:23
  • It doesn't work. When I e.g. press Enter to get a newline in the argument list, the cursor jumps outside the parentheses. – Barry Kelly Jan 15 '14 at 10:32
5

If I understand the problem correctly, here is the solution! I had the same problem.

Main Menu | Window | Preferences | <The language you are using> | Editor | Typing

In the section "Automatically close," uncheck the options you don't want.

I don't know if this functionality is new. I just started using Eclipse again and haven't ever used it much.

I found the answer on this stackoverflow page.

Community
  • 1
  • 1
David Winiecki
  • 4,093
  • 2
  • 37
  • 39
3

As you noticed, it only happens if you wait for the proposals ("intellisense") box to pop up.

The "solution" is to disable proposals under one or both of the following, although doing so is probably more of a hassle because of what you'll be giving up.

Preferences -> Java -> Editor -> Content Assist -> "Insert single proposals automatically"

Preferences -> Java -> Editor -> Content Assist -> Advanced

ben
  • 488
  • 3
  • 11