Insert Spaces, not Tabs

The tab key is great for formatting lines of code, since it will auto-indent.  However, you should not allow tab characters to be inserted in your code since it causes inconsistent formatting in various editors.  Rather, always insert spaces rather than tabs.  In Eclipse, you can do this by opening the preferences panel and choosing General → Editors → Text Editors and then selecting Insert spaces for tabs, as shown below:

C++ Code Formatting

Eclipse can be setup to format code in various ways.  I suggest that you go to C/C++ → Code Style → Formatter, choose Import and then upload this file.
c++formatting

C++ Code Templates

In Eclipse, you can control how various parts of the code are auto-generated easily.  Go to C/C++ → Code Style → Code Templates.
For a recommended style layout, choose Import and then upload this file.
c++prefs

 

Categories: eclipse

1 Comment

Installing Eclipse on OSX | Multiscale Modeling Software · November 2, 2015 at 9:27 AM

[…] C++ development in eclipse […]

Leave a Reply

Avatar placeholder