psf / black

The uncompromising Python code formatter

Home Page:https://black.readthedocs.io/en/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support line range?

laixintao opened this issue · comments

Did black support line range? Like I have huge python file to edit, and just want to format part of the file (in Vim mostly)

In Vim I see No range allowed, so did black support line range? Or just vim-plugin didn't have that feature?

Black supports # fmt: off and # fmt: on to control where it shouldn't apply any formatting. You should be able to use that to solve your problem

See #134 for a longer explanation why Black doesn't support partial file reformatting.

Thanks

Also FYI, I wrote darker with which you can apply Black formatting only to lines which have changed in the Git working tree since the last commit.