visual-studio-code

Is it possible to enable source.organizeImports without removal of unused imports?


This is what I have in my user settings.json.

"editor.codeActionsOnSave": {
  "source.organizeImports": true
},

Love the sorting, but don’t like that Visual Studio Code is removing unused imports vs greying them out.


Solution

  • Finally it's possible in 2021.

    Replace source.organizeImports by source.sortImports.

    "editor.codeActionsOnSave": {
      "source.sortImports": "explicit"
    },