Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable vscode clear/remove not used code when save file

When I save file, VSCode auto cleans the not used code, How to Disable it? I want to make VSCode not to delete any line of my code.

enter image description here

like image 823
yu yang Jian Avatar asked Jun 04 '26 02:06

yu yang Jian


1 Answers

The setting source.organizeImports removes unused imports when you save. Set the value to "never" to prevent removing unused imports.

{
    "[go]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": "never"
        }
    },
}

See also: vscode-go documentation https://github.com/golang/vscode-go/wiki/advanced#formatting-code-and-organizing-imports

like image 167
user23150924 Avatar answered Jun 07 '26 00:06

user23150924



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!