Turn off indent eclipse C/C++ - c++

I NEED to turn off auto-indent on Eclipse for C/C++ coding. It DRIVES ME NUTS to be fighting with the editor constantly for the position of the text cursor.
This is a common question, but the standard answer does not appear to work on Kepler with C/C++ extentions, so perhaps it got "unfixed"???
The standard answer I saw was to go to preferences->C/C++->editor->typing and uncheck "automatically indent" new lines and braces.
The behavior is that entering new line causes the cursor to be aligned on the new line with the block above. I want newline to end up flush left.
Thanks,
Scott Franco

Try per project settings.
C/C++ General > Formatter > Edit...
Indentation Tab
Uncheck everything.
or
Eclipse wide
Window > Preferences
C/C++ > Code Style > Formatter > Edit...
Indentation Tab
Uncheck everything.
You can't unless you join the dev team http://www.eclipse.org/cdt/developers.php and make the change yourself.

The answer is: its a feature, notgonna fix it. It happens even if you call up a plain text editor. Eclipse has bugs filed against it by others that turned into long arguments. The developers went google on it [1]
[1] "went google": Our way or the highway. We are smart, you don't work at google, so obviously you are not. Next.

Related

Finding C++ references in Eclipse

In eclipse C++ (with CDT), I would like to find all C++ references of the selected text. Ideally with the following constraints:
accessible via keyboard shortcut
a working set can be selected to restrict the search
I do NOT need to right click on my working set directory in Project Explorer > Index > Update with Modified Files, so that search results are relevant
Currently, I know:
Ctrl+Shift+G : but it searches in the whole project which is just huge. For those who know Visual Assist Plugin in Visual Studio, it is more or less the equivalent of shortcut Alt+Shift+F except Visual Assist indexer seems really faster to me, and I have never been bothered by the latency before.
Ctrl+H, then Enter : cool but if I can skip the Enter, and have a direct shortcut somehow, it would be just better
So, I have three questions:
Have you got this issue, in a big project with thousands of files, that the indexer gets in a wrong state (it is not in a running step who could explain that, it just seems wrong), so that if you modify a file, a next references search shows weird results, except if your right click on a directory in Project Explorer > Index > Update with Modified Files ? I tried to play around with Window > Preferences > C/C++ > Indexer but had not luck to improve that.
Is it possible to have a shortcut for Ctrl+H, then Enter ?
If not, is it possible to record/tune some kind of macro to avoid repeating these uncomfortable and distracting steps ?
Thanks,
Eclipse details:
Eclipse Version: Luna Service Release 2 (4.4.2)
CDT Version: 8.6.0.201502131403
Try to find "References in Project" instead of in the whole workspace. If you have several projects in your workspace, the search is slower than in only one project. First try References > In Project from the context menu to see if this command works well enough for you.
If you are satisfied with it, assign a hot key in menu Windows -> Preferences > General > Keys. Filter by text "References in Project", select the item with "Source" category. Change its hot key below and change "When" field to "C/C++ Editor".

Commit C++ Intellisense suggestion with space bar in VS 2013

I have recently been exploring C++ some after using C# exclusively for quite awhile. I'm using Visual Studio 2013 and the one thing that is bugging me to death is the inability to commit an Intellisense suggestion by pressing the space bar. I have tried to edit the commit character list in Options -> Text Editor -> C/C++ -> Advanced to accept the space bar but so far I've had no luck. Coming from C# this is very aggravating. Does anybody know if it's possible to make such a change? I know I can use Tab or Enter, but in my opinion using Space is far more fluid.
Any information would be greatly appreciated.
UPDATE: Space seems to commit some suggestions but not others. if I type "std::stri", it commits "std::string". Unfortunately, Intellisense won't commit anything created by me or even common keywords. It just adds a space after what I already typed.
Further to my comment on your question, I have installed the trial version of Visual Studio 2013 (Ultimate), and can confirm that space bar does work to complete IntelliSense suggestions. Combining all comments, it would appear that it works in the following versions:
VS 2010
VS 2012
VS 2013
Here is a screenshot of my IntelliSense settings located at Tools > Options > Text Editor > C/C++ > Advanced:
As a last resort you may want to try changing all your settings back to default, as suggested in this answer:
Tools > Import and Export Settings > Reset all settings
UPDATE: After reading JoshC's comments, I have experimented a bit more and I get the problem too. It appears to be related to whether or not the item you are trying to autocomplete is a member of a type or namespace. If it is (e.g. std::string) then space will work. If it is not (e.g. void) then it will not work (but for some reason, tab will work). As per this link, you can manually invoke the "List Members feature" by pressing CTRL+J in which case on a blank line it will include items which are in the global namespace - however this is clearly not a practical solution.
I have no idea why it discriminates between space and tab in this way. If anyone is aware of a workaround please let me know and I will edit this answer again.
The following would seem to imply that there is no solution for C++:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2656132-support-committed-by-pressing-the-space-bar-in-c
When using Visual Studios 2012 for coding in C++, how do you autocomplete code selected in IntelliSense? (see comments)

How do I turn off auto-formatting in VS2013 for C++?

VS2013 has added auto-formatting for C++. My personal opinion on auto-formatting is that it's ultimately harmful for developers but I have to accept not everyone agrees. What bugs me is that I can't seem to disable auto-formatting completely. I have unchecked every checkbox under Tools->Text Editor->C/C++->Formatting->General yet when I type:
void f ()
VS2013 replaces this with
void f()
That's not the code-standard in this specific project which means I have to go back and insert a space. There are other examples where I have to fight against VS.
I don't want to change the spacing settings because
I work in multiple projects with different code standards
I don't believe in auto-formatting so I just want it to get out of my way
I just want VS to not modify my code automatically.
PS. I am not against that VS can format code but I want to invoke that manually
You can turn off automatic C / C++ /C# code formatting by going to the Options dialog from the Tools menu, selecting the Text Editor → C / C++ / C# → Formatting → General page, and unchecking all the boxes there. You'll still be able to manually format when all of the auto-formatting settings are turned off.
I know this isn't exactly the answer you're looking for, but you can preserver that void f () formatting if you go to Tools > Options > Text Editor > C/C++ > Formatting > Spacing and under Spacing for function parantheses you check the option Insert space between function names and opening parentheses of argument list.
I also had this problem and unchecking all the checkboxes in the formatting options did not help.
It turned out that this was caused by an option in the plugin “Visual Assist X” from Whole Tomato Software.
In my case this problem could be solved by going to “Visual Assist Options”-->”Corrections” and unchecking the Checkbox “Format after paste”.
It's a bug in VS 2013 beta that it cannot be turned off completely, see issue submitted by FuleSnabel: http://connect.microsoft.com/VisualStudio/feedback/details/797716/turning-off-auto-formatting-for-vs2013-c-only-seems-to-partial-disable-auto-formatting.
Some possible workarounds:
If you just peek into some projects which have different/weird style: if an unwanted auto-formatting happens, then you can perform one undo step, this should undo only the auto formatting part of the operation and not your contribution. Fortunately these two (or sometimes more auto formatting steps) are not grouped together into one command probably for this exact reason: you can go back and override it. It is annoying though if that happens all the time. You can configure the behavior to match your style, but you say you have project with different code styles.
Tools/Import and Export Settings... - you can export the specific settings for a certain project and then import it later. This will save .vssettings XML format file. If it's about just a specific file type, than it can be just a few kilobytes long. Unfortunately this requires manual steps. The best would be if these settings could be overridden from the solution configuration file or even the project configuration file, could be part of them.
Note, that this second point is problematic if you really work parallel in your projects with simultaneously open Visual Studios. In this case that settings will be saved finally what the last closed VS instance had I think.
Having different auto formatting saved for solutions can be a feature request for next release (certainly not make it to VS 2013). What I usually come across is the tab/space indentation behavior differences, it's the most common difference in project styles. Indentation also can be configured individually for most file types, but as as in your case, projects can differ, and then it becomes annoying.
Just remember that resharper can also override the indentation/formatting settings. You can turn that off by doing this
ReSharper -> Options -> Environment -> Editor -> Editor Behaviour -> Auto-format on closing brace (un-check this).
To turn off automatic brace completion, go to:
Tools > Options > Text Editor > All Languages > General > Automatic brace completion
...then uncheck "Automatic brace completion".
Go to:
Tools->Options->Text Editor->C/C++->Formatting->Spacing
Then deselect or select the boxes that pertain to the code type you are writing.

VC++ debugging: is it possible to skip cursor?

As we all know, in debugging mode, Visual C++ support "Run to Cursor" feature, so, I'm curious to know whether it support simillar feature "Skip cursor". In other words, my app just skip the line of code.
Anybody can help me?
PS: I'm using Visual C++ 2010.
Yes you can do this easily.
Once you're at a breakpoint, you can right-click on a line of code just like you do to "Run to cursor", but instead, choose "Set next statement".
It's explained on MSDN here.
You can run to the previous line, and then skip over it using 'set next statement'.
I do not know such feature. But i think you can:
comment current line of code
use "Apply code change".
"step over"

Preventing Visual Studio 2008 (C++) from removing indentation tabbing in white-space only lines

Suppose I am writing an if statement in C++ with VS2008. I'm inside a function and therefore indented (a tab from the left margin, say). I type if{, hit enter and I'm now two tabs from the marging - I'm happy :-)
I move the cursor up a few lines to copy something and then back to just under the if{. Lo and behold, my cursor is now right against the left margin and I've lost my indentation. Grumpy! >:-(
I'm wasting my time retyping tabs and it's driving me bonkers. Please help me unlock the secret setting that allows me to get on with my work.
Edit: Incidentally, whilst developing in C# I experience the desired behaviour. It's just C++ that loses the auto-indentation.
To the best of my knowledge, there is no setting to get this to work in VS2008.
In VS2010, it does behave how you would expect.
If you can, I would recommend using VS2010. If you are doing c++-cli, you can set the project to use the .Net 3.5 framework, and then it compiles using VS2008. If you are doing vanilla c++, you can go into the project property pages, General and set the Platform Toolset to v90 to get it to compile using VS2008. Of course, you could just compile using VS2010 if that's an option for you.
If you view white space (Edit > Advanced > View White Space), you can see that when you press enter the tabs are not put into the file until some text is typed. When you click away, Visual Studio doesn't remember that you were indented.
A potential solution to you problem is in Tools > Options > Text Editor > C/C++ > General, you can check "Enable virtual space". This allows you to put the cursor anywhere and once you type a character it adds the tabs/spaces up to the cursor.
The option in C# that is missing from C++ is the check box "Indent block contents" in Tools > Options > Text Editor > C# > Formatting > Indentation.