13

Let's say I'm editing a line...

obj.fooBar(x, y, z);

I want to change the method name to fooSomethingElse, but keep most of the arguments. If I delete all or part of the name, and then use content assist, it completes the method name, but starts a new arg list...

obj.fooSomethingElse(arg1, arg2)(x, y, z)
                     ^---- this arg is highlighted for editing

I often have to delete "(arg1, arg2)". I can turn off "fill method arguments" in preferences and then I only have to delete "()", but it's still annoying. Is there another command to complete only the method name. Ideally it would just be a separate command and key combo from the general purpose content-assist, so I can invoke either one as needed.

Rob N
  • 15,024
  • 17
  • 92
  • 165

2 Answers2

17

Essentially you are looking for a way to toggle between inserting and replacing via content assist. The default behavior is to insert. You can toggle this behavior while inside the content assist selection dialog by pressing and holding the Ctrl key while selecting the completion.
More inforation - http://blog.deepakazad.com/2012/06/jdt-tip-toggle-between-inserting-and.html

Deepak Azad
  • 7,903
  • 2
  • 34
  • 49
  • Yup that's hit, hold down control while I hit enter, to select one of the methods, and it does what I want. Thanks. – Rob N Jul 09 '12 at 21:43
  • 1
    I find the IntelliJ approach easier to use: enter to insert, tab to just replace (This way is little time consuming) – Sudip Bhandari May 26 '17 at 07:22
0

I think you just need to press tab instead of enter to autocomplete it. Then it will keep your existing parameters.

jjathman
  • 12,536
  • 8
  • 29
  • 33