Nori Heikkinen wrote:
hey all, this is kind of off-topic, but i figured this is the community most likley to have dealt with this sort of thing in the past, and be opinionated about it. i've been editing a lot of code over the past few months that was originally saved to disk with hard tabs for indenting. i can't work with hard tabs, and so managed to reformat the entire thing to use spaces (basically a "s,^I, ," iirc) before i began my massive overhaul of this file. now it's time to check it into CVS. i don't want every single line to show up as different just because of tab characters, so i need to find a good solution on how to transform my indents back into tab characters. clearly the reverse -- "s, ,^I," -- won't just work, as there are places where two spaces exist that i wouldn't want a tab. is there some way to open the file in emacs (in which i assumer it was originally written; i use vim) and run it through a re-indentder with hard tabs on? or could i do this in vim? suggestions & opinions welcome. thanks a lot, </nori>
I've done this with mixed results. In general if you're going to work on projects, its a good idea to come up with your format conventions first. :)
However, sometimes you just inherit code and really there isnt much you can do about it. Its right up there with cuddled elses, some people do it, others dont. CVS is going to have huge deltas due to indent formatting. If I'm going to change the format of the code, I will usually commit ONLY format changes with a comment to that effect, then commit code changes. It makes it easier to see what was actually changed that way. When you do huge reformats, you're going to wind up in merge hell if you have lots of developers or multiple branches of the code. It'll be difficult to tell what actually changed, vs what was merely moved around.
For things like indenting, etc, you could always adjust what you have your tabstop set to.
-- Mental (Mental@NeverLight.com) "The Torah... The Gospels... The Koran... Each claimed as the infallible word of GOD. Misquoted, misinterpreted, misunderstood, and misapplied. Maybe that's why he doesn't do any more interviews." - sinfest.net CARPE NOCTEM, QUAM MINIMUM CREDULA POSTERO. GPG public key: http://www.neverlight.com/pas/Mental.asc
Description: PGP signature