PSU uses emacs?

D-Man dsh8290 at rit.edu
Wed Jan 24 16:36:06 EST 2001


On Wed, Jan 24, 2001 at 10:56:42AM +0000, Ray Drew wrote:
| [snip]
| 
| I'm having problems getting the indentation right with gvim. I've got
| the following in my .vimrc file:
| 
| au FileType py set ts=4
| au FileType py set sw=4
| au FileType py set expandtab on 
| au FileType py set ff=unix
| 
| as far as I can make out from the docs, this should set those options
| for all .py files. Tabs appear as 4 chars in gvim but when viewed in
| an IDLE edtor window, tabs appear as 8 and throw a syntax error when
| imported (files originally created in IDLE with tab space of 4). Do I
| need to do anything else to get this to work?

This results from the interpreter counting a <TAB> character as equal
to 8 spaces, but you are looking at it like it is 4.  This causes
problems if you mix tabs and spaces.

IMO, you shouldn't set ts at all.  Leave it at 8.  Instead, set sw=4
(as you did) and sts=4 .  sts is softtabstop.  It affects the way vim
acts when you do indentation operations like >> << and press the <TAB>
button on the keyboard.

I leave tabstop=8 and set shiftwidth and softtabstop to the
indentation level I want.  Also, setting expandtab (as you tried to
do) is good for replacing tab chars with space chars (based on the sts
variable) when inserting.  

If you only use space characters in files you will have no trouble
when switching editors.

HTH,
-D

| 
| Ray Drew
| CIA UK
| 




More information about the Python-list mailing list