On Jul 22, 2:02 pm, ptn <[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> I have a weird problem.  Say I have a .py file with some functions in
> it, like this:
>
>     # (...)
>     def foo():
>         print("bar")
>
> When I open it and add a line to one of the functions,
>
>     # (...)
>     def foo():
>         troz = "bar"
>         print(troz)
>
> I get the following traceback from the interpreter:
>
>     Traceback (most recent call last):
>       File "SOMEWHERE/example.py", line ??
>         troz = "bar"
>                           ^
>     IndentationError: unindent does not match any outer indentation
> level
>
> And so I'm forced to rewrite the function entirely just to add the new
> line.
>
> 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
> formatoptions-=ta2w
>
> But the problem didn't go away.  I don't think this has anything to
> do
> 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?
>
> Thanks,
>
> Pablo Torres N.

That isn't the standard. With that setup tabs will show up as 4
spaces, and still confuse you. You want this:

set shiftwidth=4
set tabstop=8
set softtabstop=4
set expandtab

tab characters in the file will show up as 8 characters long (which is
how the python interpreter sees them also) but pressing tab will
insert 4 spaces.

Matt
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to