run black or flake8 on python code in markdown

generalised to any files

  1. vic visual select lines of python codes in markdown code block
  2. :'<,'>!black -q - to replace the visually selected lines with the formatted standard output of the external black command (see :help filter)
  3. :'<,'>w !flake8 - to use w to echo flake8’s output instead of replacing visually selected lines (see :help :w_c)

Alternatively, I can open the output in a split

  1. :'<,'>w !flake8 - > quickfix.vim to pipe the output into quickfix.vim
  2. <leader>el