Resharper setting to analyze code only when I press Enter at the end of the line? - resharper

While I'm editing a line of code, I'd like to have access to Code Completion, etc.
But most of the time while editing, before having pressed Enter, syntax color coding, squigglies, and variable type hints appear and move things.
I would like to finish editing the line and analyze the line only when I press Enter.
I've checked the documentation, and I can turn it off entirely under Code Inspection > Settings. But there's no setting there to wait until I'm done.
I have found that you can swap Tab and Enter, but that's for Code Completion only.
I have the latest stable Visual Studio 2022 and the latest stable Resharper version.
Any solution that doesn't change a character or spacing on the line I'm editing is eligible. So it can analyze the line as long as it doesn't do this. But I'd prefer to defer analysis until I press the Enter key at the end of the line.

No, that's not possible. As you already mentioned, you can disable certain things, but you cannot defer its execution. This is a basic paradigm across Visual Studio and ReSharper (Rider as well) to give you feedback while editing, not after. Maybe using VS Code with the C# extension is an option for you.

Related

Forward slash key not working in VS2019 code editor

Since a few days (I don't know exactly when it started) the forward key in VS2019 is not working in the code editor. No matter how many times I press it, it doesn't do anything.
It also doesn't work in the seach box in the menu bar (labelled 'Search (Ctrl+Q)') nor in the search box which appears with Ctrl+F.
It does work in other places, like the solution explorer search box (Ctrl+;) and in the resource editor.
The forward slash is working in any other application that I tried (including Visual Studio Code and MS Excel). The question mark (Shift+/) is working everywhere, including in the code editor window. Even AltGr+/ is working (producing the Spanish upside down question mark).
I tried all other keys, including the AltGr combinations. They all work fine. Keyboard layout is US International.
The foward slash key doesn't work in the code editor when typing it on the laptop keyboard, and doesn't work when typing it on an external keyboard, or via an RDP session.
I am running Windows 10 Pro 64-bit, version 20H2, build 19042.685. System is up to date.
Visual Studio Professional 2019, 16.8.3, also up to date.
What is causing the forward slash key to fail?
How can I solve this problem?
(Too long for a comment.)
The OP indicated that the problem was resolved after resetting the keyboard shortcuts, which suggests that / was set as a keyboard shortcut either by accident or perhaps by an installed extension.
However, the question remains in such cases of how to identify what a particular keyboard shortcut is assigned to, in order to turn off just that one shortcut as opposed to resetting all.
Visual Studio does not appear to provide a place to see the list of all active keyboard shortcuts. An alternative is to go to Tools / Import and Export Settings / Export Selected / All Settings and save a .vssettings file with all the current settings. That is a plain text file with extended XML sections, and the keyboard shortcuts can be found under the following node (reformatted for readability):
<Category name="Environment_KeyBindings" ... >
<Version>16.0.0.0</Version>
<KeyboardShortcuts>
<DefaultShortcuts>
<Shortcut Command="View.ViewCode" Scope="Global">F7</Shortcut>
...
</DefaultShortcuts>
<UserShortcuts>
...
</UserShortcuts>
</KeyboardShortcuts>
</Category>
One of the <Shortcut> lines would have been listing / before the reset, and the Command attribute on that line indicated the assignment, so that it could be located and turned off individually in Tools / Options / Environment / Keyboard.
#dxiv Your comment made me check the shortcuts. Tedious job, scrolling through those hundreds of options). Nothing. Then I clicked the Reset button. That solved the problem.
In my case, the CodeRush extension was the guilty party. "Selection comment" gets set to use / upon installation. WTG DevExpress ......
https://docs.devexpress.com/CodeRushForRoslyn/120205/coding-assistance/selection-tools/comment-uncomment-selection
Update:
Also adding a screenshot of it in VS 2022 to help people find it:

Resharper's settings often reset spontaneusly

Resharper's settings often reset spontaneously. This happens almost always after Visual Studio has been restarted, but I don't found exact regularity.
This continually repeats on every Visual Studio on every machine I am work.
This is corrected by pressing "Apply Scheme" inside "Resharper options -> Keyboard & Menus".
But why is this happening and how to prevent it from happening again?
In case you have a non-English keyboard language installed on a machine, you may probably experience this issue https://youtrack.jetbrains.com/issue/RSRP-449737. Visual Studio can forget custom shortcuts if you change keyboard languages between launching/closing Visual Studio instances.
You may try reproducing the same issue on any custom shortcuts as described in ticket's comment:
Suspend ReSharper. Restart VS.
English is an input language. Assign shortcut "Ctrl+/" to the Edit.NavigateTo command using Tools | Options | Keyboard (see 1.png)
Restart VS. Shortcut is assigned (see 2.png)
Close VS. Switch to a non-English input language. Start VS. The shortcut becomes "Ctrl+\" (see 3.png and 4.png)
Close VS. Your language is still an input language. Start VS. Shortcut is lost (see 5.png and 6.png). It's 100% reproducible for Russian. You can use any VS command instead Edit.NavigateTo, it does not matter. May be you can try to apply the shortcut in French and then switch to English.

Maddening auto-format behavior with Visual Studio 2019 / Resharper that I cannot disable

This started happening for me in Visual Studio 2019 but does not happen in 2017. I cannot figure out how to stop it.
Something I do all the time is make use of Resharper's reformatting. Suppose I have little block of code like this:
Scan = scan;
Target = target;
IsDone = true;
ShouldAlign = false;
I want to align it up to look all nice and neat. So I select my block of code and I either use the menu or a keyboard shortcut to invoke Resharper's autoformat to line up the equals signs. Voila! Looks great, Here is the reformatted code, exactly as it appears, right after I've reformatted. Note the code is still selected:
But then all I have to do is I click anywhere else in the whitespace of that document, and Boom! Everything gets undone
It is as if VS2019 runs its own "Format Selection" command when I click away But I never did that. (but if I manually do, it has the same effect)
However if instead of just clicking away on the whitespace I, click the menu area of Visual Studio and then click the document whitespace, no problem. No reformat.
Just now I've just finished comparing Visual Studio 2017 and 2019 editing settings side-by-side next to each other. I've compared every single edit/formatting/spacing setting I can possibly find. Both Visual Studio's and Resharper's. They are identical except in those few cases where VS 2019 has some new setting that 2017 did not.
This still happens even when all of VS2019's "automatically format" settings are off
I'm asking the same question of the Resharper folks but I think it has to do with the interaction of the two.
Is anyone else seeing anything like this? It's driving me nuts.
After several hours of this, I have finally discovered that that problem was neither Visual Studio nor Resharper. It was actually a THIRD extension I use (also very common) for C++ files called Visual Assist".
VA has its own "format after paste" option. I am guessing that it must detect the reformat/click away as a "paste" operation and it reformats it according to Visual Studio's settings.
Once I disabled that in single, Visual Assist option VS2019 (as I apparently already had in 2017) everything worked well.

Visual Studio: Undo-redo of replace-action does not scroll editor window

I did some find-and-replace actions in my C++ code with visual studio:
only single find-and-replace actions (did not use “replace all”)
only one file affected (did not change multiple files at the same time)
thus, a very simple case!
Then I wanted to undo these changes. So I pressed ctrl-Z one time. This had the desired effect. The latest change (which was still visible in the current screen) was undone.
But I also wanted to undo the remaining changes. These changes where currently not visible on the screen. So I expected the editor to scroll there when pressing ctrl-Z.
But unfortunately the editor did not scroll to the position of the undo when I pressed ctrl-z.
The undo worked, however. I checked by scrolling to the position manually.
Then I tried it with redo. Same result: Redo worked, but the editor did not scroll to the position of the redo.
Finally I tried if this also happens when I undo-redo other types of changes (not made by the “find and replace” functionality).
Result: Undo-Redo worked correctly and also scrolled correctly!
Thus: It seems only changes by the “find and replace” functionality are affected by this problem.
Did you also have this problem and found a solution?
Please help me!
Regards Gerhard
I am having the same thing happen in Visual Studio Ultimate 2012 (Version 11.0.60610.01 Update 3).
It might sound like it's not that important, but it is really hurting the usability of this otherwise great IDE!
PS I've been using VS since the 90s, I still haven't found anything better. I wish MS would put macros back into VS, even if it's VBA (or Python)

Tab behavior Resharper Intellisense Options

A product like Resharper has many settings, and I can't seem to find the right settings to get the exact behavior I desire from it.
The behavior I am trying to change is this:
Suppose the endresult I want is
but the line currently is
As you expect I start typing:
and after a tab I get this
but I wanted it to become
Does anyone know how I can change the Resharper settings in such a manner that my desired behavior is realized?
Thank you.
EDIT: Note that tab does perform the desired behavior in the default VS Intellisense.
In this particular case, here's what you should do:
Go to ReSharper > Options > Environment > IntelliSense > IntelliSense Behavior, and set Automatically insert parentheses after completion to Opening only.
Now, with the caret right before SomeMethod(), type in Math.Ab, and complete Abs with Enter, as correctly suggested by Rob H. You'll end up with Math.Abs(SomeMethod();
Finally, press Ctrl+Shift+Enter to invoke the Complete Statement, which in this case will insert the required parenthesis at the end of the statement, and put the caret on the next line.
Keep in mind though that this might not be the optimal solution provided that you probably have plenty of other usages of code completion that could conflict with this kind of settings change.
If that kind of similar code modification is required in multiple places, you should possibly create a search and replace pattern instead.
Hitting Enter instead of Tab will insert without overwriting, although you then end up with
Math.Abs()SomeMethod();

Resources