code-d icon indicating copy to clipboard operation
code-d copied to clipboard

[improve docs] organize imports upon save

Open jabbalaci opened this issue 1 year ago • 0 comments

I could set up to autoformat my code upon save. However, import lines were not sorted.

From the docs I could figure out how to do it: move the cursor on an input line and press Ctrl+q Ctrl+s. But how to get it automatically? When I save my code, I wanted it fully autoformatted: 1) format the code, and 2) sort the import lines.

Actually, it's possible, but I had to ask it on a forum. Add these lines to your settings.json:

"[d]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": "always"
    }
  },

Please add it to the documentation so people find it easily.

jabbalaci avatar Jun 17 '24 16:06 jabbalaci