具有以下选项集:setlocal formatprg=autopep8\ -aa\ -
当我在Visual中选择一行并按gq时,autopep8会对该行进行修改,但也会更改该行的缩进:它默认为4个空格的缩进,而不管该行当前的缩进级别如何。我希望它假设这些行是正确缩进的,所以不要对它们进行干预。
类似地,如果我为--indent-size 8设置autopep8开关,它将将行推送到缩进级别为8个空格。请注意,如果视觉选择足够大,足以包含顶级缩进(即没有缩进的地方),则所有内容都会正确地缩进。但在提交之前,我倾向于视觉选择较小的块。
发布于 2014-06-27 10:00:01
你需要给--indent-size 0。所以我的.vimrc有这样一行:
" Use gq to clean up code
" Indent to 0 because otherwise it pushes selected lines to the given
" indent-size, no matter the current indent level of the line.
au FileType python setlocal formatprg=autopep8\ -aa\ --indent-size\ 0\ -https://stackoverflow.com/questions/24449056
复制相似问题