当我编辑“*.py”文件而不是任何其他文件时,如何让 Tab 键插入 4 个空格?
根据 Vim and PEP 8 -- Style Guide for Python Code 的建议,我安装了 vim-flake8 (和 vim-pathogen)。这会在违反 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
最佳答案
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4
甚至更短:
au Filetype python setl et ts=4 sw=4
关于python - 仅在 python 文件中将制表符扩展到 vim 中的空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9986475/