Skip to content

Instantly share code, notes, and snippets.

@L3viathan
Last active March 28, 2019 11:59
Show Gist options
  • Select an option

  • Save L3viathan/101b5baa7eda050aae52d39b8ed1b100 to your computer and use it in GitHub Desktop.

Select an option

Save L3viathan/101b5baa7eda050aae52d39b8ed1b100 to your computer and use it in GitHub Desktop.
black, but as an operator
function! Blackify(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
silent exe "'[,']!black --quiet -"
let &selection = sel_save
let @@ = reg_save
endfun
" non-standard, but eh:
nnoremap <silent> <leader>== :Black<cr>
nnoremap <silent> <leader>= :set opfunc=Blackify<cr>g@
vnoremap <silent> <leader>= :!black --quiet -<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment