Finding C++ references in Eclipse - c++

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".

Related

How can I disable live code analysis in Visual Studio 2017?

Where can I disable live code analysis in Visual Studio 2017? This pops up every time I start my solution. I do not need this:
I've followed this support document from Microsoft but unchecking "Enable full solution analysis" seems to have no effect on live code analysis. Then I found a solution for Visual Studio 2012 but also without any luck.
So it seems to me that live code analysis is a complete different thing not managed by full solution analysis. It is running immediately as a background process task after (re)starting the solution. Anyway, how can I get rid of this?
It's not possible In VS2017
only if all Roslyn installed components in Extensions and Updates are disabled.
I'm using a workaround, global setting forces analyses runs at build on solution projects, in editor runs at any change but now editor is a lot faster with bellow workaround:
Tools -> Options -> Text Editor -> C# (in my case) -> Advanced -> Perform editor feature analysis in external process (experimental) -> select it and save.
UPDATE: It's possible in VS2019 16.5
More details on closed issue (solution is for VS2019):How to disable live code compilation/analysis in Visual Studio 2017?
I had a similar problem. There is this huge temp initialization file in the project, 50K+ lines. Whenever I opened it, Live code analysis would kick in and VS would eat up CPU up to 50%.
I was able to turn it off by creating an empty rule set and set it on Code Analysis section of the project's properties. Now It looks like it's running, only for a few seconds and then it stops since there is no rule to apply.
I don't know if this exactly applies to your problem but here how it goes.
To create an empty rule set;
Click "Choose multiple rule sets" from the ComboBox under "Run this ruleset" :
Make sure no rule set is checked in the "Add or Remove Ruleset" window.
Click "Save As" button:
In file dialog, save your new rule set. I named mine as "EmptyRuleSet".
After saving process, new empty rule set should be selected in the ComboBox. Click the "Open" button below :
In rule set details, uncheck all the sub rule sets and there is only "None" under "Action" column:
Save the changes on project properties.
After these steps, you can see that "Live Code Analysis" run empty for a few seconds when you open a file or start the solution, then it stops. You may have to restart the VisualStudio.
I was able to make VS 2019 run at acceptable speeds using the 'Auto cancel long running auxiliary operations on typing' setting. The default 'Automatic' setting appeared ineffective, although changing it back now doesn't seen to re-introduce the very slow background processing issue.
I have no idea if this stops/aborts/prevents more useful features, although it seems to "tame" VS 2019's background processing.

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.

Visual Studio 2010 Improperly underlining code/comments with red error line when there is no error

I am working on a rather large project, and I am having strange problems with the IDE in terms of error checking and somewhat with IntelliSense.
Usually if I were to type something boneheaded, like "int a = "aa";", it would underline "aa" in red. However I am seeing VS do this to random parts of my code when I make insignificant changes.
For example:
/*
Some comment here, just going to stretch it out for my example..
*/
int proto1();
int proto2();
If I make changes to other parts of the project, sometimes random functions will get underlined, and even part of a comment. Like just 30 minutes ago it underlined the equivalent of half of that comment beginning in the middle of the word "comment", also it underlined all of int proto1(); and part of int proto2();
I would post screenshots but I am bound by contract not to disclose any work, and I can't easily replicate it in smaller projects.
I don't understand why it does this. When I compile the project, any fake errors and underlining it did goes away and it compiles fine. The point though, is there are no errors. It's making up random errors and underlining random lines/words/half words. I would also like to note that there seems to be a large delay in loading new intellisense information, almost by 2-3 minutes or longer.
I'll try and reproduce it in an unrelated project and post here if I can. However, any help would be appreciated.
Thanks!
*Edit: Forgot to note that hitting the space key several times will on occasion correct the errors however this isn't reliable and does not always work.
Intellisense sometimes can really get stuck with complicated code. I guess until VS2012 release comes out, there's nothing we can do.
There's however one trick that I'm using if this happens - switch your build configuration Debug -> Release and then back again. You don't have to wait, you can just click two times on this drop-down box. It should refresh IS cache and make red error underlines dissappear.
Intellisense is often off, but make sure you have latest updates installed.
I just installed sp1 yesterday and lot of Intellisense issues went way.
I see this is a stale question but some may find this helpful.
I just had this same issue. I tried many of the solutions outlined here and elsewhere. I finally tried running Visual Studio as another user (Shift Right Click Run As Different User) and the issue did not present. I then logged into my computer as another user and deleted the profile of the user I was having the issue with.
If your profile is important to you or there is information within it that is important I highly recommend backing up relevant information first. If you don't understand what information you profile contains make sure you do prior to deleting it.
1) Log in as different user (with admin privileges) than you want to delete
2) Open Properties for Computer
3) Advanced system settings (on the left side)
4) Settings for User Profiles (in the middle)
5) Select the profile you want to delete and click the delete button
6) Reboot
Credit to:
https://superuser.com/questions/63017/how-do-i-delete-a-user-profile-on-a-windows-7-machine-that-is-part-of-a-domain
I had the same issue, and in my case it was mostly related to library functions and types defined in libraries. This one fixed it for me:
Open command line parameters. You can use following to reach there:
Project > ProjectName Properties > Configuration Properties > Linker > Command Line
In the Additional Options box at the bottom add
/I "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
You will of course need the correct path where Visual Studio is installed.
Bingo! I hope it works for you too. :)

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.