Install Black in Vim 8 and format when saving
This method of installing Black uses the built-in plugin management in Vim 8+.
sudo rm -rf ~/.vim/black mkdir -p ~/.vim/pack/start/black/plugin curl https://raw.githubusercontent.com/psf/black/21.6b0/plugin/black.vim -o ~/.vim/pack/start/black/plugin/black.vim
Next time you open a Python file in Vim, Black will install.
Add the following to
~/.vimrc to format with Black every time you save.
autocmd BufWritePre *.py execute ':Black'