vim and tabs in Python code

super_banane at yahoo.com super_banane at yahoo.com
Fri Jan 28 10:20:06 EST 2000


When I want to modify somebody else's Python code with
vim, I run into problems quite easily. Say the previous
author has used blanks for indentation instead of
tabs as I do, and the following code gets a syntax
error:

<blank><blank><blank><blank>FirstLineOfCode
<one 4-blank tabulation>SecondLineOfCode

both look like:

    FirstLineOfCode
    SecondLineOfCode

The first line was initially in the file, the second
one was added by me. Since vim adds tabulations by
default, how is it possible to add blanks instead?

I guess that will not solve it: say that now my vim
configuration is adding blanks. Now I am editing somebody
else's code who uses tabulations, or a mix between
tabulations and blanks, how do I add a line without
first doing surgery on the file to check out what
the indentation convention was (if there is any, that is)?

I guess the whole problem comes from the fact that:

- The indentation is seen by the interpreter but not
  by me, e.g. a 4-blank tab is seen the same as 4 blanks
  but not interpreted the same. Hard to tell something
  invisible is different from something else invisible.
- Whatever intelligence you put in vim, will not help
  other kinds of editors, will it?

I would appreciate, though, if anyone could give an
advice about how to configure vim or preprocess
somebody else's code to make it fit any given convention
for indentation.

--
Nicolas


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list