Black does not support "Format Selection" command - VS Code error

user13700226 picture user13700226 · Jun 17, 2020 · Viewed 12.5k times · Source

I need to indent my python file in Vs Code. I followed the normal procedure,

On Windows Shift + Alt + F
On Mac Shift + Option + F
On Linux Ctrl + Shift + I

But my question is every time when I try to format python file it it says

Black does not support "Format Selection"

So someone can explain what's going wrong here? My python version is Python 3.7.6

Vs code details:

Version: 1.46.0 (user setup)
Commit: a5d1cc28bb5da32ec67e86cc50f84c67cc690321
Date: 2020-06-10T09:03:20.462Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0

OS: Windows_NT x64 10.0.18363 

Answer

YaOzI picture YaOzI · Aug 27, 2020

In my situation (select black as the Python Formatting Provider in VS Code Settings), I encountered this warning everytime when I pasting some text into the editor.

And the official documentation of VS Code has a solution specifically for it:

When using the black formatter, VS Code issues the following warning when pasting source code into the editor: Black does not support the "Format Select" command.

To prevent this warning, add the following entry to your user or workspace settings to disable format on paste for Python files:

"[python]": {
    "editor.formatOnPaste": false
}