Reformat a Python file to have 4 space indentations

前端 未结 7 1472
灰色年华
灰色年华 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:46

    The vim plugin vim-autoformat integrates the formatter autopep8 into vim automatically, if it is installed. You can format the whole file, or the visually selected part using a single keystroke.

    More importantly, vim-autoformat takes the relevant settings of your .vimrc into account, e.g. if you have

    set shiftwidth=4
    

    in your .vimrc, it will pass this information on to autopep8.

提交回复
热议问题