This is a plugin aimed to autoformat python statement. When you finish type a line and type <Cr> to start a new line, the previous line will be formatted automatically.
It also boost the start new line time for large python file. No delay at all.
if you write python file like that:
a =1+2<cursor>
that looks ulgy, right? Don't worry. With the help of this plugin, you simply press return button in insert mode
or normal mode
, then the code will be formated automatically by autopep8 into this:
a = 1 + 2
<cursor>
Use your plugin manager of choice.
-
- Add
Bundle 'https://github.com/sillybun/autoformatpythonstatement'
to .vimrc - Run
:BundleInstall
- And change to the plugin directory and run in shell
./install.sh
- Add
-
- Add
Plug 'https://github.com/sillybun/autoformatpythonstatement', {'do': './install.sh'}
to .vimrc - Run
:PlugInstall
- Add
Warning: for macos m1 users, if you use arm64 vim (chech it via
:version
), please make sure that you runinstall.sh
using arm64 python (e.g. downloaded from arm homebrew)
For m1 user, install.sh
will call /opt/homebrew/bin/python3.9 setup.py build
to build core library.
Everytime you type enter, the previous line will be formatted automatically.
:ChangeFormatCurrentLineMode
: this command is to switch the plugin on/off state.
let g:autoformatpython_break_long_lines = 0
If this value is set to 1, long lines will be broken into several shorter lines automatically.