views:

121

answers:

3

Hi there,

I'm developing a small project with some friends and we're facing some indentation issues. Each of us is using a different editor (we all have different favorites :) and we also are on different operating systems.

What is the best solution to be able to all develop together and set our programming editors so indentation and encoding is the same? What settings do you recommend and why?

+1  A: 

If you are all insistent to have your own indentation settings, then you will need to use exclusively the tab character to indent the code. (Provided your various editors support this).

This approach is counter to the general consensus of using spaces and only spaces for indenting purposes.

mjv
A: 

Whatever you do, I recommend converting tabs to a common number of spaces. I know Eclipse can do this on the fly, but I'm not sure if edits like gvim can. In any case, with all spaces it is not up to the individual editors/IDEs to interpret how many spaces make up a tab. Also, if anyone's using a Windows editor/IDE, set it to use Unix-style newlines, so that you don't get the annoying ^M at the end of every line when you edit in a different OS.

Kaleb Brasee
gvim can do that, so can emacs, and most others. Both of the aforementioned can also handle windows-style line endings without trouble. That said, your point is valid if the goal is to homogenize the way the code looks, but that seems to be the opposite of what the OP wants. Unless I misunderstood, he wants a way to preserve everyone's individual indenting preferences, which would seem to imply using tabs.
rmeador
I don't think that's what he was going for, I think he wants indentation and encoding the same regardless of what editor people are using.
Kaleb Brasee
+3  A: 

You should have your version control system handle the line ending problems. In SVN, the "svn:eol-style" property can be set to "native" to handle auto-converting the line endings. I assume your code is ASCII or UTF8 so you don't have problems with character encoding.

As far as formatting goes, you'll have to choose roughly some style, such as where to put the braces, but there's no reason you have to have the same indent style, provided you use the same number of indents. That's a confusing statement, so allow me to explain: nearly every IDE ever has the ability to set tab widths to any value you want. If one team member likes to indent 2 character widths, another 4, that's fine. One tab character stored in the file can display either way based on IDE settings. Just configure your IDE to indent with tabs and then set the tab widths per your desires.

(at the risk of starting a flame war, this is why I am solidly in the camp of tabs in the tabs vs spaces war. strangely, the spaces folks seem to consider this very feature the reason to use spaces... I will never understand them).

rmeador