如何正确设置VIM自动缩进编辑Python文件 - * .py [英] How to setup VIM autoindentation properly for editing Python files - *.py

查看:345
本文介绍了如何正确设置VIM自动缩进编辑Python文件 - * .py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有麻烦设置VIM(7.1.xxx)编辑python文件。
缩进似乎被打破(最佳4个空格)。
我遵循了我通过Google找到的一些教程。仍然没有效果:/
请帮助。

I've troubles setting VIM (7.1.xxx) for editing python files. Indenting seems to be broken (optimal 4 spaces). I've followed some tutorials I found via Google. Still no effect :/ Please help.

推荐答案

我在macbook上使用这个:

I use this on my macbook:

" configure expanding of tabs for various file types
au BufRead,BufNewFile *.py set expandtab
au BufRead,BufNewFile *.c set noexpandtab
au BufRead,BufNewFile *.h set noexpandtab
au BufRead,BufNewFile Makefile* set noexpandtab

" --------------------------------------------------------------------------------
" configure editor with tabs and nice stuff...
" --------------------------------------------------------------------------------
set expandtab           " enter spaces when tab is pressed
set textwidth=120       " break lines when line length increases
set tabstop=4           " use 4 spaces to represent tab
set softtabstop=4
set shiftwidth=4        " number of spaces to use for auto indent
set autoindent          " copy indent from current line when starting a new line

" make backspaces more powerfull
set backspace=indent,eol,start

set ruler                           " show line and column number
syntax on               " syntax highlighting
set showcmd             " show (partial) command in status line

显示与缩排/制表符相关的内容)

(edited to only show stuff related to indent / tabs)

这篇关于如何正确设置VIM自动缩进编辑Python文件 - * .py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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