Reformat a Python file to have 4 space indentations

前端 未结 7 1473
灰色年华
灰色年华 2020-12-23 16:39

I\'m editing a Python file that uses two spaces for programmatic indents - I prefer 4 spaces. In my .vimrc I have the following settings related to indentation:

<         


        
7条回答
  •  春和景丽
    2020-12-23 16:40

    The best current way to reformat Python, fix many other issues, and also make it PEP8 compliant is to use autopep8. See this related question. So after you've installed autopep8 (e.g. pip install autopep8) in vim you do:

    :%! autopep8 -
    

    There's also a vim-autopep8 plugin to make things even simpler.

提交回复
热议问题