Bug 79886 - Problems with indentation in C++ project
Summary: Problems with indentation in C++ project
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 2.0.2   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-01 11:29 EST by Guy CLA
Modified: 2004-12-05 02:19 EST (History)
0 users

See Also:


Attachments
A file that shows the indentaion problem (66.50 KB, application/octet-stream)
2004-12-01 11:30 EST, Guy CLA
no flags Details
A picture that shows that the 'Format' option appears on the Edit menu in Linux (80.30 KB, image/x-png)
2004-12-02 03:46 EST, Guy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Guy CLA 2004-12-01 11:29:29 EST
I have an indentation problem in some of my c++ files.
The problem is that sometimes the indentation of 'if' and 'else' clauses of the 
same level moves the 'else' clause inside or outside and not show it in the 
same level of the 'if'(This problem is acute when the 'if' clause contains some 
if levels inside it).
I want to emphasize: when I open in Eclipse a file that is indented well in 
other editors (like xEmacse or VI),the indentation breaks!
In the attached file you can see an example of this problem.
Comment 1 Guy CLA 2004-12-01 11:30:39 EST
Created attachment 16261 [details]
A file that shows the indentaion problem
Comment 2 Andrew Niefer CLA 2004-12-01 11:38:30 EST
Coming from a basic text editor, I would guess that your indentations are a
mixture of tabs and spaces depending on their depth.  In CDT, tabs are displayed
with a default size of 4 (where in a text editor they would likely be 8).  This
would account for the misalignment of your blocks.  
Try going to Window->Preferences->C/C++->Editor->Displayed Tab Width and change
it to 8 to see if this fixes things.  
If that does fix it, then this isn't really a bug.
Comment 3 Alain Magloire CLA 2004-12-01 11:50:48 EST
> Try going to Window->Preferences->C/C++->Editor->Displayed Tab Width and change
> it to 8 to see if this fixes things.  

And you will probably need CDT-2.1 (now RC4), there was
a bug in the previous version when doihg the Displayed tab.
Comment 4 Guy CLA 2004-12-02 03:44:05 EST
Thanks. I did as you said and it fixed the problem. I think you should add it 
to the documentation.
I have another 2 problems with the indentation (I wasn't sure if I should open 
them in different separate bugs, so I wrote them here)
1. I noticed that only on Linux machines, for C++ files,  the option 'Format' 
appears in the Edit option in the menu bar (I attached a file that shows 
it),but this option doesn't do anything ! Is it supposed to work?
2. Ctrl +I doesn’t indent a line (or selected lines) but only shift them right.
Is it supposed to work like that and not like it  works for Java's files? 
How can I indent a line or the all file?
Thanks a lot,
Guy
Comment 5 Guy CLA 2004-12-02 03:46:00 EST
Created attachment 16286 [details]
A picture that shows that the 'Format' option appears on the Edit menu in Linux
Comment 6 Alain Magloire CLA 2004-12-02 10:26:14 EST
> How can I indent a line or the all file?

CDT-2.1 do have a framework for ISV to plug there
"Formatters", but by default there is "NONE", see the preference
page C/C++ --> Code Formatter.

We did however, send to the mailing list an example plugin
based on the "GNU Indent", that we'll enable formatting for CDT-2.1.

Having a default formatting is something we are looking for CDT-3.0.

For the "GNU Indent" plugin look at the cdt-ui-dev
mailing list archive.  You will find the plugin and
instructions, let us know(via the mailing list) if
if works for you.

> Thanks. I did as you said and it fixed the problem.

Allright changing the state.
Please verify.
Comment 7 Guy CLA 2004-12-05 02:19:14 EST
What about the first paragraph in my latter:
"I noticed that only on Linux machines, for C++ files,  the option 'Format' 
appears in the Edit option in the menu bar (I attached a file that shows 
it),but this option doesn't do anything ! Is it supposed to work?"