What's the canonical vi setting for Python indentation

J.Spies j.spies at hccnet.nl
Wed Dec 1 17:48:48 EST 1999


William Park wrote:
> 
> On Wed, Dec 01, 1999 at 10:19:06AM +1100, Chris WRIGHT wrote:
> > I've tried to find out the "OK" indentation settings for python with vi,
> > and a troll through deja-news found some hints (like don't do indent =
> > 4). Yet I seem to also remember some advice to the contrary?? I want
> > indentation to be 4 characters, and readable by/ acceptable to emacs
> > python-mode, and to pass tabnanny...
> 
> I use 'vim', and my ~/.vimrc contains (among other things)
>     set smarttab        " use 'shiftwidth' at beginning of line
>     set shiftwidth=4    " use 4 spaces for indenting
>     " indentation after Python keywords
>     autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
> 
>         Yours truly,
>         William Park
> 
> >
> > I think that this should go in the faq...(Couldn't find it from
> > www.python.org search)
> >
> >
> > cheers
> > and thanks
> >
> > chris wright
> > --
> > Dr. Chris Wright
> > Deputy Director, Intensive Care Unit
> > Monash Medical Centre

It's not in the FAQ, but in the doc/howto/editor

Add to your ~/.vimrc file:

autocmd BufRead, BufNewfile *.py syntax on
autocmd BufRead, BufNewfile *.py se ai

if you want to enable syntax coloring and automatic indentation.


Jaap Spies
Hogeschool Drenthe

Let's keep Peace in Mind




More information about the Python-list mailing list