vim的标签长度​​因.py文件而异

Amx*_*mxx 8 python vim indentation

在我的~/.vimrc设置选项卡给我2个空格长

set shiftwidth=2
set tabstop=2
Run Code Online (Sandbox Code Playgroud)

但是,当我打开.py文件时,标签长度为4个空格.我没有python文件的具体配置.~/.vim/after是空的,搜索py不会引发任何可疑线.

你有过这样的经历吗?如何解决这样的行为?

Júd*_*nén 10

它在一般的Python filetype插件文件($VIMRUNTIME/ftplugin/python.vim)中定义:

" As suggested by PEP8.
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
Run Code Online (Sandbox Code Playgroud)

它应该是符合PEP 8的.


@Carpetsmoker补充道:

关于这个讨论的VIM-dev的@名单上.

您可以使用此功能重置此项~/.vimrc; 例如:

aug python
    " ftype/python.vim overwrites this
    au FileType python setlocal ts=4 sts=4 sw=4 noexpandtab
aug end
Run Code Online (Sandbox Code Playgroud)

或者通过添加配置设置$HOME/.vim/after.