Thursday, June 14, 2012

JDT Tip: Toggle between inserting and replacing content assist


When content assist is invoked on an existing identifier, it can either replace the identifier with the chosen completion or do an insert.

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. The highlighted text is overwritten.

If you wish the completion to overwrite without pressing the Ctrl key then you can select 'Preferences > Java > Editor > Content Assist > Completion overwrites'.

6 comments:

  1. This is one such feature I am looking from quite some time. Thanks for sharing this !

    ReplyDelete
  2. Thanks Deepak. The default setting drives me crazy all the time, and I'm very happy to learn it can be changed.

    ReplyDelete
  3. I always change the default to "replace"... I wonder why new workspace are configured with "insert".

    ReplyDelete
    Replies
    1. I actually prefer the insert mode to be default, and just use the Ctrl key trick to replace when required. I guess a lot of others also have the same preference.

      Delete
  4. @Jeremie: I fully agree. "Insert" is nasty ;-)

    @Deepak: I just tried the Ctrl key and it seems it's actually not a "toggle" thingy. While I'm in replace mode it does not lead to temporary insert.

    ReplyDelete
    Replies
    1. @Eike Ctrl key works as a toggle for me in both modes. Can you double check? If it still does not work, can you please open a bug :-)

      Delete