VIM and tab to space migration
Graham Dumpleton
grahamd at dscpl.com.au
Thu May 6 18:43:18 EDT 2004
Brian Quinlan <brian at sweetapp.com> wrote in message news:<mailman.266.1083757569.25742.python-list at python.org>...
> Right now I'm working in an environment where tabs were mandated as the
> indentation style for Python. I've managed to persuade everyone to
> switch to 4 space indentation.
>
> The problem is that we now have a migration problem. Most of our
> develoeprs are using VIM which, AFAIK, is not intelligent enough to
> detect the current indentation style of a file. Modifying all of our
> source files at once to use spaces and then getting everyone to change
> their .vimrc is a posibility but not desirable because everyone would
> have to check in their work (whatever it's state) at the time of
> migration. Does anyone have any suggestions? Ideally, there would be
> some way to tell VIM to use the file's exsiting indentation style. That
> way I could slowly switch to spaces over time.
I have the following to lines in my .exrc file:
map ^Ktu 1G!Gunexpand -a^M
map ^Kte 1G!Gexpand^M
The ^K and ^M are the equivalent control characters.
I then type ^Ke and it will pipe the whole contents of the file being edited
through "expand" which will turn all tabs into appropriate number of
spaces. Typing ^Ku does the opposite.
You could run the "expand" program outside of vi as well as part of a shell
script and do all your files at the same time.
More information about the Python-list
mailing list