How to get VIM indentation and Python playing nicely?

Kenneth McDonald kenneth.m.mcdonald at sbcglobal.net
Mon Jun 14 00:28:07 CEST 2004


I've just started to use VIM as a Python editor. However, getting
indentation to work nicely is giving me fits. I've tried a bunch
of different settings--shiftwidth, ts, etc etc.--to get tabs
working the way I want, but can't get things quite right. I'm
hoping some of you python/VIM users can help.

Here's what I want:
1) A tab displays in a width equal to four spaces.
2) <tab> always produces a tab char; it does not substitute spaces.
3) <del> (in edit mode) always deletes the previous character;
it doesn't do anything fancy.
4) <ret> (in edit mode) produces a new line below with the
same leading whitespace as the previous line _unless_ the 
previous line ended with ':', in which case an additional
tab character is added.

Here's what I'm getting (settings are shiftwidth=4, ts=4, 
every other tab-related setting that I can find that was
8 is four, and I've tried lots of other stuff at the same
time, such as notabexpand). Not all of this happens all
the time, but at least one of these behaviors happens no
matter what settings I've tried:
1) <del> dedents by 8 spaces: ^D dedents by 4 (which is what
I want.
2) <tab> sometimes indents by 4, and sometimes by 8, at
different places in the same file _using the same settings_.
3) Typing a ':' can cause the entire line (including what
has alrady been typed) to dedent or indent. In my view,
this is a very bad no-no.

Hopefully the solution to this sort of thing is easy. If
not, then I guess the search for an editor resumes...


Thanks,
Ken



More information about the Python-list mailing list