.py文件的vim标签长度不同 [英] vim's tab length is different for .py files

查看:219
本文介绍了.py文件的vim标签长度不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的~/.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标签长度不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆