只在python文件中将tabs扩展到vim中的空格?

2024-03-28 19:31:44 发布

您现在位置:Python中文网/ 问答频道 /正文

在编辑“*.py”文件而不是其他任何文件时,如何让tab键插入4个空格?

根据Vim and PEP 8 -- Style Guide for Python Code的建议,我安装了vim-flake8(和vim病原体)。当违反PEP8风格的指导方针时,这会发出警告。这很好,但是我希望在编辑python文件时首先自动展开选项卡。我想让tab键在编辑其他类型的文件时实际插入制表符。

换句话说,当我编辑python文件并且只编辑python文件时,我希望应用以下内容:

set expandtab       " tabs are converted to spaces
set tabstop=4       " numbers of spaces of tab character
set shiftwidth=4    " numbers of spaces to (auto)indent

Tags: and文件oftopy编辑stylevim