仅在python文件中将选项卡扩展到vim中的空格

仅在python文件中将选项卡扩展到vim中的空格

本文介绍了仅在python文件中将选项卡扩展到vim中的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在编辑"* .py"文件而不是其他文件时,如何使Tab键插入4个空格?

How do I have the tab key insert 4 spaces when I'm editing "*.py" files and not any other files?

遵循 Vim和PEP 8的建议《 Python代码指南》 ,我安装了vim-flake8(和vim-pathogen).当违反PEP8样式准则时,这会发出警告.这很棒,但是在编辑python文件时,我会首先将选项卡自动展开.我想让Tab键在编辑其他类型的文件时实际插入标签.

Following a recommendation from Vim and PEP 8 -- Style Guide for Python Code, I installed vim-flake8 (and vim-pathogen). This gives warnings when PEP8 style guidelines are violated. This is great, but I would for tabs to be expanded automatically in the first place when editing python files. I would like to have tab key actually insert tabs when editing other types of files.

换句话说,我要在编辑python文件和仅python文件时应用以下内容:

In other words, I want the following to apply when I'm editing python files and only python files:

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文件中将选项卡扩展到vim中的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:09