Function editing with Vim throws IndentError

ptn tn.pablo at
Tue Jul 22 23:02:57 CEST 2008

Hi everybody,

I have a weird problem.  Say I have a .py file with some functions in
it, like this:

    # (...)
    def foo():

When I open it and add a line to one of the functions,

    # (...)
    def foo():
        troz = "bar"

I get the following traceback from the interpreter:

    Traceback (most recent call last):
      File "SOMEWHERE/", line ??
        troz = "bar"
    IndentationError: unindent does not match any outer indentation

And so I'm forced to rewrite the function entirely just to add the new

I thought that my problem was the w option from formatoptions, so I
changed my .vimrc file to this:

    augroup filetype
      autocmd BufNewFile,BufRead *.txt set filetype=human
    augroup END
    autocmd FileType human setlocal formatoptions+=ta2w
    autocmd FileType lisp,scheme,python,c,java,vim setlocal

But the problem didn't go away.  I don't think this has anything to
with the tabs and spaces, because I have them set up like this:

    set tabstop=4 shiftwidth=4 expandtab

which is the standard way to handle them.

The scripts I load are: qbuf, TagList, indent/python.vim and a reduced
version of the standard python.vim

Could someone provide some pointers?


Pablo Torres N.

More information about the Python-list mailing list