How to turn off automatic deletion of unused imports in VS Code?

Viewed 65

VS Code automatically deletes unused imports and even more annoyingly it deletes imports that are used, but commented out. So for example, if I was to save this code:

from pprint import pprint
# pprint("foo")

It would remove the first line. So how can I turn this feature off, because it constantly forces me to rewrite the imports?

1 Answers

Check your settings.json (User and Workspace) for the following settings, delete this configuration or change it to false.

    "editor.codeActionsOnSave": {
        "source.fixAll": true,
    },
Related