问题描述
在我的~/.vimrc
中,我将制表符设置为2个空格长
In my ~/.vimrc
I set tab to me 2 spaces long
set shiftwidth=2
set tabstop=2
但是,当我打开.py
文件时,制表符的长度为4个空格.我没有python文件的特定配置. ~/.vim/after
为空,搜索py
不会引发任何可疑行.
However when I open a .py
file, tabs are 4 spaces long. I don't have specific configuration for python files. ~/.vim/after
is empty and searching for py
doesn't raise any suspect lines.
您经历过吗?如何解决这种行为?
Have you ever experienced that? How to solve such a behaviour?
推荐答案
它是在常规Python文件类型插件文件($VIMRUNTIME/ftplugin/python.vim
)中定义的:
It’s defined in the general Python filetype plugin file ($VIMRUNTIME/ftplugin/python.vim
):
" As suggested by PEP8.
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
应该符合 PEP 8
@Carpetsmoker添加:
@Carpetsmoker adds:
对此进行了讨论在vim-dev @列表上.
There is a discussion about this on the vim-dev@ list.
您可以在~/.vimrc
中使用它来重置它;例如:
You can reset this using this in your ~/.vimrc
; for example:
aug python
" ftype/python.vim overwrites this
au FileType python setlocal ts=4 sts=4 sw=4 noexpandtab
aug end
或通过在$HOME/.vim/after
中添加配置设置.
Or by adding config settings in $HOME/.vim/after
.
这篇关于.py文件的vim标签长度不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!