Format current line immediately in INSERT mode as soon as you press ENTER:
gq
or :Neoformat
.Install the plugin with vim-plug:
" Tell vim-plug to install python module with post-update hook
Plug 'skywind3000/vim-rt-format', { 'do': 'pip3 install autopep8' }
" By default, it will be triggered by `ENTER` in insert mode.
" set this to 1 to use `CTRL+ENTER` instead, and keep the
" default `ENTER` behavior unchanged.
let g:rtf_ctrl_enter = 0
" Enable formatting when leaving insert mode
let g:rtf_on_insert_leave = 1
Enable plugin for current buffer:
:RTFormatEnable
Then you go.
Some of my other plugins may also interest you: