Quick fixes to quickly resolve errors

Quick fixes are one or more possible corrections the ST-editor offers for found errors.
A "light bulb" icon images/download/attachments/406487235/IconError-QuickFix-version-1-modificationdate-1530103977081-api-v2.png on the border left of the code indicates that quick fixes might be available. Note that the icon images/download/attachments/406487235/IconError-QuickFix-version-1-modificationdate-1530103977081-api-v2.png is only a hint; even with images/download/attachments/406487235/IconError-QuickFix-version-1-modificationdate-1530103977081-api-v2.png shown, it might turn out that no quick fixes are available.

Use the quick fixes to quickly resolve found errors.
For example, if you assign a program within the PLC-object but this program cannot be found in any ST-object, the name of the program is underlined and images/download/attachments/406487235/IconError-QuickFix-version-1-modificationdate-1530103977081-api-v2.png appears on border left of the name to indicate the error and the available quick fix. You can use the quick fix to change the name to an already existing program.But quick fixes are not only useful to resolve errors that accidentally occurred. Another common usage is to intentionally enter an "incorrect" code, for example by referring to a variable that is not declared yet. Then, you can use the command Quick Fix (if applicable) to create the declaration.

The command Quick Fix is available in 2 places:

  1. when editing the →resource containing the error
    How to see the correction proposals for it and select one of the proposals:

    Possible initial steps

    Successive steps

    Result of all steps

    Click onto the highlighted error. In menu Edit or from the context menu of the ST-editor, select Quick Fix. Alternative: Press Ctrl+1.
    Result: A list is displayed providing all available correction proposals.

    Double-click the proposal you need or select it (by using the mouse or the cursor movement keys) and press the Enter-key.

    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Each proposal shows a preview when selected in the list.

    The error highlight incl. images/download/attachments/406487235/IconError-QuickFix-version-1-modificationdate-1530103977081-api-v2.png disappears as soon as the correction is applied without producing any errors.

    Click on images/download/attachments/406487235/IconError-QuickFix-version-1-modificationdate-1530103977081-api-v2.png on the border left of the code.
    Result: A list is displayed providing all available correction proposals.

    Point to the highlighted error.
    Result: The description of the error as well as the available correction proposals are displayed.

    Double-click the proposal you need. (A preview is not possible here.)

  2. the Problems view
    See "Quick-fixing the problem" for the steps how to select a correction proposal in this view.

Restriction

It might not be possible to apply the quick fix, if there are syntax errors within the concerned ST-element.