1

simple question: What is the shortcut to autocomplete () { } in Java Eclipse?

I've been searching like crazy to find what the key combination for this is.

Medzin
  • 33
  • 4
  • I think your question was answered here: [Question 6202223](https://stackoverflow.com/questions/6202223/auto-code-completion-on-eclipse) – Christian Will Aug 12 '17 at 04:07

2 Answers2

0

Put your mouse cursor within a class, write your method name and press Ctrl+Space. It will show you the suggestion whether you want to create new method stub (method). Press Enter and it will generate the method definition with an empty body.

Example: hello (Ctrl+Space) and then Enter key

Output:

private void hello() {
    // TODO Auto-generated method stub

}

This way you can generate a method stub. Works for methods to create within functions.

However there is no existing way to just generate only "(){}" in eclipse. It's kind of copy paste thing which should forever remain copied somewhere somehow in eclipse so that you just paste it with some shortcut keys inside the eclipse IDE

To auto-close an opened brace or parentheses, see Dawood ibn Kareem's answer below

howlger
  • 31,050
  • 11
  • 59
  • 99
jarvo69
  • 7,908
  • 2
  • 18
  • 28
0
  1. Go to the Window | Preferences dialog.
  2. Select Java | Editor | Typing.
  3. In the "Automatically Close" section on the right, switch on the checkboxes for everything you want automatically closed - so parentheses and braces.
  4. Click OK.
Dawood ibn Kareem
  • 77,785
  • 15
  • 98
  • 110