Indentation Style which is best?

Started by
28 comments, last by Promit 18 years ago
which indentation style do you feel is the best? and can you recommend me the best C++ text editor?
Advertisement
The best is which ever YOU like most.

As far as text editors, I prefer the Visual Studio (Visual C++) editor. You can get the Express version of Visual Studio 2005 for free. For me it's the best, but it may not be for others. Best is relative.


-SirKnight
Personally, I like the 2 space style.

For example:
void main(){  cout << "I like this indentation style!" << endl;    if (true)  {    cout << "See? It's nice." << endl;  }}


This method let's me keep track of whether my brace brackets are lined up properly, and are complete.

As for editors, there are quite a few available. Check out the Forum FAQ
Tabs until indent level, spaces for mid-line alignment. That way, any other people who have different tab sizes will see it how they want to see it and won't have mid-line spacing problems.
Personally, I use BSD/Allman style indentation with 4 space wide hard tabs. And since this will probably come up sooner or later, I use .NET's naming conventions in all languages that I code in.

As for editor, I stick to VS. The vim and emacs people can go on all they like, but I don't buy any of it (and I'm familiar and comfortable with both editors). Simple and direct works fine.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Nypyren
Tabs until indent level, spaces for mid-line alignment. That way, any other people who have different tab sizes will see it how they want to see it and won't have mid-line spacing problems.


I've never understood why the majority of people don't seem to do that.
Quote:Original post by Roboguy
Quote:Original post by Nypyren
Tabs until indent level, spaces for mid-line alignment. That way, any other people who have different tab sizes will see it how they want to see it and won't have mid-line spacing problems.


I've never understood why the majority of people don't seem to do that.


Can you show me an example?
Quote:Original post by Promit
Personally, I use BSD/Allman style indentation with 4 space wide hard tabs. And since this will probably come up sooner or later, I use .NET's naming conventions in all languages that I code in.


Yes, that's the indent style I use, except I prefer 2 space tabs. My naming conventions are pretty much a mixture of various other conventions. I do, however, seem to favor the java naming conventions for functions.

Example: void removeObject(...);

That's only because I find it more visually appealing, though.
Quote:Original post by Tradone
Quote:Original post by Roboguy
Quote:Original post by Nypyren
Tabs until indent level, spaces for mid-line alignment. That way, any other people who have different tab sizes will see it how they want to see it and won't have mid-line spacing problems.


I've never understood why the majority of people don't seem to do that.


Can you show me an example?


int main() {	int array = {1,	             2,	             3,	             4};	if (/*...*/) {		// ...	}}


Note which spaces are tabs and which aren't. It will all be lined up regardless of the tab size used.
Are the .NET naming conventions the same as the Java naming conventions?

This topic is closed to new replies.

Advertisement