question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide option to organize imports as part of format

See original GitHub issue

Header added by @mjbvz

TypeScript Version: 4.4.2

Search Terms

  • format / formatting / formatter
  • organize imports / sort imports

This feature request is to provide a new option that would automatically run organize imports as part of format.

While VS Code could implement this itself today, handling this on the TS Server would have a few key advantages:

  • It would let us edit the document in a single go. Otherwise we have to first format the document and then organize imports. This would cause some flickering and may result in multiple undo stops
  • Other consumers of TS could benefit from the feature

Testing microsoft/vscode#48150

This would be awesome.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:15
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
Xaz16commented, Dec 12, 2018

Hi guys

It is really annoying that my prettier have conflict with auto organize imports. @mjbvz Could you please tell if you have any progress on it?

As workaround I use

"editor.formatOnSaveTimeout": 1000

to give prettier a chance to make correct formatting.

9reactions
quicksnapcommented, Jul 12, 2018

Would love this action to happen before formatting, since may users use prettier. Currently, I organize imports (which does not respect prettier formatting rules) and then format with prettier (manually or onSave)

Read more comments on GitHub >

github_iconTop Results From Across the Web

vsc-organize-imports - Visual Studio Marketplace
Open Visual Studio Code's command bar (ctrl+shift+p); Write: 'vsc Organize Imports'; Press Enter to execute the organize. Extension Settings.
Read more >
How to Automatically Organize Imports in VSCode - YouTube
Learn how to organize your imports when you save a file in VSCode----If you like cooking, checkout my side project: ...
Read more >
IntelliJ IDEA code reformat options - Stack Overflow
In IDEA 2018, you can hit Ctrl + Alt + Shift + L and the reformat file pop-up will appear. Then you can...
Read more >
Auto import | IntelliJ IDEA Documentation - JetBrains
Press Ctrl+K or select Git | Commit from the main menu. · Click Show Commit Options and in the Before commit area, select...
Read more >
format-imports - npm
format -imports [options] [FILE1 FILE2 ...] This command formats a number of given files. If no files provided, it'll read the source from ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found