How to fix "Black doesn't support Format selection command" Github Copilot, Python dev

Nicolas Goffin 30 Reputation points
2025-01-22T16:58:52.38+00:00

I'm learning python (v 3.13.1) development, and using VS community edition 2022.
With Github Copilot, everytime I use TAB key for auto-completion, I've got a pop up telling me : Black doesn't support Format selection command.
Cb4PGq8r

The same issue has been resolved in VS Code for years ago, but the problem remains in Visual Studio Community.
Any clue or hint will be greatly appreciated.

Community Center Not monitored
0 comments No comments
{count} vote

Accepted answer
  1. Pradeep M 9,765 Reputation points Microsoft External Staff Volunteer Moderator
    2025-01-23T03:54:44.8033333+00:00

    Hi Nicolas Goffin,

    Thank you for reaching out to Microsoft Q & A forum. 

    The issue occurs because Black only supports formatting entire files, not specific code selections. To resolve this in Visual Studio Community, go to Tools > Options > Text Editor > Python > Code Style and disable selection-based formatting. Alternatively, save the file (Ctrl+S) to allow Black to format the entire document. You may also consider using a selection-based formatter like autopep8 or switch to Visual Studio Code for better compatibility with GitHub Copilot and Black. 

    Please feel free to contact us if you have any additional questions.     

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.  

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.