I want to use yapf
to reformat parts of python buffers.
Yapf can take input from stdin yapf -l 30-40
. This would produce output that is the whole buffer but with lines 30-40 reformatted. I can then generate diff between the file.py
as it is in vim buffer and yapf output. But I don't know how to apply this diff to a current buffer inside of formatexpr
.
:diffpatch
command?patch
:) runningdiff -N |patch
works just fine. Besides, you can also throw some vimscript at the problem, temporarily save the buffer, apply the patch and reload the file from the disk