I know this question has been asked many times, but I'm not finding a solution to my problem in particular, mostly because I can't even really identify the problem.
Here's the timeline of events:
- open old python file (written with python2.7) - everything is fine
- change key bindings to execute .py files with python3 instead of python2.7 - as expected, lot's of
IndentError
s, but file is still the same structure/layout/number of spaces/tabs - added
expandtab
to my .vimrc - no moreIndentError
s do to inconsistency anymore, but newIndentError
s all over the place because the structure of my source code is now all out of whack. - I remove
expandtab
from my .vimrc and I still get the same out of whack source, even if I kill-session, quite iTerm, pull the source fresh from github...WHY!?
Just to be clear, there are only TWO things that have been altered in my vimrc in like the past few months and both alterations were made this morning. The first was remaping <F9>
to issue a shell command for python3 instead of 2.7, which DID NOT affect the structure of my source code. The second change was adding expandtab
which messed everything up...removing expandtab
doesn't return my vim experience to the way it was prior to adding it.
The structural alterations to my source are semi-uniform, so let me try and explain what's actually happening.
What used to look like:
class GUI():
def __init__(self):
suite of code
now looks like:
class GUI():
def __init__(self):
suite of code
and it's like this across the board for what seems like all nested suites of code...in other words, the first expansion of tabs into 4 spaces works fine, but instead of expanding tabs nested further within the first tab, it looks like it just deletes the tab instead.
There are other weird things going on, but I can't really see a pattern.
Any ideas what's going on?
tabstop
of 8. Vim is either displaying or expanding with the assumption thattabstop=4
. Do you have the original source from before you edited the files with the bad vim settings?tabstop=8
because I've had the same .vimrc (withtabstop=4
) since before I even knew python.tabstop=8
, I can select the single tabs on the 8-space indents. And python in mixed indent mode treats tabs as eight spaces. I don't know how your vim configuration was working to show it before.tabstop=4
instead? edit: or should I just changetabstop
back to 8?%s/\t/(eight spaces)/g
. You should not have tabs in python code.