VIM“升级”到 Python 文件上的 expandtab 和 tabstop=8

dot*_*hen 6 vim kubuntu python ubuntu

将我的操作系统从 Kubuntu 12.10 重新安装到 Kubuntu 14.04 后,VIM 在编辑 Python 文件时改变了它的行为。虽然重新安装所有文件类型收到noexpandtabtabstop=4集,现在在Python这些价值观expandtabtabstop=8,还检查通过VIM行为,也可以通过询问VIM set foo?

非Python文件保留noexpandtabtabstop=4行为,我喜欢。

该目录.vim.vimrc在重新安装过程中没有被触及。可以看出.vimrc几个月内没有任何文件被触及(除了无关的.netrwhist):

 - bruno():~$ ls -lat ~/.vim
total 68
drwxr-xr-x 85 dotancohen dotancohen 12288 Aug 25 13:00 ..
drwxr-xr-x 12 dotancohen dotancohen  4096 Aug 21 11:11 .
-rw-r--r--  1 dotancohen dotancohen   268 Aug 21 11:11 .netrwhist
drwxr-xr-x  2 dotancohen dotancohen  4096 Mar  6 18:31 plugin
drwxr-xr-x  2 dotancohen dotancohen  4096 Mar  6 18:31 doc
drwxrwxr-x  2 dotancohen dotancohen  4096 Nov 29  2013 syntax
drwxrwxr-x  2 dotancohen dotancohen  4096 Nov 29  2013 ftplugin
drwxr-xr-x  4 dotancohen dotancohen  4096 Nov 29  2013 autoload
drwxrwxr-x  5 dotancohen dotancohen  4096 May 27  2013 after
drwxr-xr-x  2 dotancohen dotancohen  4096 Nov  1  2012 spell
-rw-------  1 dotancohen dotancohen   138 Aug 14  2012 .directory
-rw-rw-r--  1 dotancohen dotancohen   190 Jul  3  2012 .VimballRecord
drwxrwxr-x  2 dotancohen dotancohen  4096 May 12  2012 colors
drwxrwxr-x  2 dotancohen dotancohen  4096 Mar 16  2012 mytags
drwxrwxr-x  2 dotancohen dotancohen  4096 Feb 14  2012 keymap
Run Code Online (Sandbox Code Playgroud)

虽然.vimrc自重装以来一直被触动,但只有我测试才知道问题出在哪里。

我怎么知道什么是settingexpandtabtabstop

旁注:我什至不确定我应该在这个问题的内置帮助中阅读什么。我从 ":h 插件" 开始,但除了向我显示以下插件已加载(可能相关)之外并没有帮助:

                                                standard-plugin-list    
Standard plugins
pi_getscript.txt Downloading latest version of Vim scripts
pi_gzip.txt      Reading and writing compressed files
pi_netrw.txt     Reading and writing files over a network
pi_paren.txt     Highlight matching parens
pi_tar.txt       Tar file explorer
pi_vimball.txt   Create a self-installing Vim script
pi_zip.txt       Zip archive explorer

LOCAL ADDITIONS:                                local-additions
DynamicSigns.txt - Using Signs for different things
NrrwRgn.txt   A Narrow Region Plugin (similar to Emacs)
fugitive.txt  A Git wrapper so awesome, it should be illegal
indent-object.txt         Text objects based on indent levels.
taglist.txt     Plugin for browsing source code
vimwiki.txt   A Personal Wiki for Vim
Run Code Online (Sandbox Code Playgroud)

Ing*_*kat 8

您可以通过以下方式检查这些值的更改位置

:verbose setlocal ts? et?
Run Code Online (Sandbox Code Playgroud)

可能是通过以下添加的行$VIMRUNTIME/ftplugin/python.vim

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

您可以通过~/.vim/after/ftplugin/python.vim包含以下内容的脚本撤消此操作

setlocal noexpandtab shiftwidth=4 softtabstop=0 tabstop=4
Run Code Online (Sandbox Code Playgroud)

或者,如果您想为每个项目配置选项卡,而不是全局,请添加

let g:python_recommended_style=0
Run Code Online (Sandbox Code Playgroud)

到项目的.vimrc. 之后,python 插件将不会强制执行 PEP8 建议,您可以自由地在 proect 的.vimrc.