psf/black

Support line range?

laixintao opened this issue · 5 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?

zsol commented

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

ambv commented

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.