Search code examples
delphidelphi-10.4-sydney

Delphi. How to stop editor from autoinserting comments?


In Delphi 10.4 Sydney, if you select a comment, for example //xxx and then press press { on your keyboard, the editor will automatically replace the selected text/comment with {//xxx}.

The expected behavior would be to have only { on the screen, instead of {//xxx}.

How do I stop this behavior?

I disabled all my IDE experts, so this must be from the IDE itself.


Solution

  • This is a general feature not related to comments.

    If you have anything selected and type an opening bracket like ( or {, you will automatically surround the selection with this bracket. For instance, if you select cat and type (, you will end up with (cat).

    This can be particularly annoying when the IDE helps you with an if statement: If you type if and then a space, the IDE automatically inserts if True then with True selected. If you then type ( (for instance, if you want to type (a = 1) and (b = 4)), you will end up with if (True) then, and not if ( then.

    To disable this feature, go to Tools, Options, User Interface, Editor Options, Key Mappings, Enhancement modules and deselect Smart Surround Keys:

    Screenshot of dialog box