Visual Studio 2015 - CodeLens toggle on/off with keyboard shortcut - visual-studio

I would like to have a quick keyboard shortcut to turn on/off this feature. The feature is useful, but sometimes I want to look only at code and this feature distorts the code visual appearance.
I have bound EditorContextMenus.CodeLens.CodeLensOptions to a keyboard shortcut, but this is too slow because the Options menu takes too long to open. I would really like to have shortcut that toggles this feature on and off.
How can I do this? Did I miss some option in Environment->Keyboard or is there some add-on that can help?

To automate the Options dialog, you can create the following command in Visual Commander and assign a keyboard shortcut to it:
DTE.ExecuteCommand("EditorContextMenus.CodeLens.CodeLensOptions")
System.Windows.Forms.SendKeys.Send("{TAB} {ENTER}")

Interesting. Codelens already has some keybindings associated with it. If you press down ALT, it shows numbers over the indicators (references, source control, test), but as far as I know there isn't one to turn on/off the indicators. I'll take this feedback and file a bug for the team that owns the codelens UI at Microsoft.

Related

Multiple keybinds to same command in Visual Studio (i.e. not vscode)

I am specifically using Visual Studio 2022 and would like to have two separate keyboard bindings to open the terminal (View.Terminal).
I found the answer whilst writing this, just adding new keyboard shortcuts doesn't seem to remove the previous one(s) but this wasn't obvious throught the GUI. To change keyboard shortcuts one goes to Tools>Options>Environment>Keyboard where one can see and set keyboard shortcuts. In my case it wasn't obvious because I had one keyboard shortcut per keyboard layout and the GUI only shows the keyboard shortcuts for one keyboard layout at a time.

Assigning a shortcut to Visual Assist's quick actions

In plain Visual Studio there is the Alt+Enter shortcut, which brings up a popup with quick fixes and improvement suggestions.
I am using the Visual Assist plugin for c++ development, which lets me right-click on a item and open 'Quick Actions and Refactorings (VA)' menu.
I would like to combine these two options into one: Having the advanced features in the easy accessible Alt+Enter shortcut without reaching to the mouse and right-click. Anyone knows how to assign a custom shortcut to 'Quick Actions and Refactoring'? Or any suggestions how to get rid of the tedious right-click?
Assigning shortcuts always works like this in Visual Studio:
Tools -> Options -> Environment -> Keyboard
Find the right identifier for the desired action, which is
VAssistX.RefactorContextMenu in your case.
Assign the desired shortcut Alt+Enter for the scope Text Editor and there you go.
Note, that this replaces Visual Studio's original Alt+Enter functionality, not blending them together.

Visual Studio code completion like ctrl+k in netbeans?

My question is there code completion for Visual studio like in Netbeans where you cycle the buffer with ctrl+k, when you type something?
There's now a nice extension called Simple Autocomplete which adds one command simpleAutocomplete.next that you can map to a shortcut of your choice.
No, there isn't a similar feature in Visual Studio.
The traditional Visual Studio autocomplete is using intellisense.
When you start typing, intellisense may bring up a drop down with suggestions. In that case you can tab to complete using the current suggestion or use the arrow keys to choose another.
Ctrl-Space (or Alt-Right arrow) will bring up this intellisense menu if it's not up.
I find it does a pretty good job overall.
Some extensions like Resharper or Visual Assist offer their own code completion or other similar features (like Suggestion List for Visual Assist).
I know it's been ages since I asked this question but I found the next best thing to do this. What I would suggest is to use VsVim extension and to use Vim's anyword completion; however, in order for this work, what must be resolved is the keyboard shortcuts that conflict:
Go to "Tools options" in Visual Studio.
Then go to VsVim category(alternatively you can search "VsVim" and
should bring the options) and click keyboard.
As far as I know vim deals with this type of completion with these keys
CTRL+P and CTRL+N so what we do is to let Visual Studio give up
these keybindings and let VsVim deal with it by Selecting from the drop
down of the keys(CTRL+P and CTRL+N) and let it be "Handled by VsVim".
I hope this has helped someone out.

How to remove all resharper keybindings?

I like resharper fine, but with the new pricing, the trial ran out and I want to try life without it.
Except after disabling all the Resharper commands are still bound in my keyboard options! So ctrl+, doesn't fall back to the standard VS behavior because its bound to Resharper.Resharper_GotoRecentEdits which is, of course, disabled.
Even clicking Reset in the keyboard options does not remove the keybindings.
So what the heck. How do I get rid of all the resharper stuff? It is currently suspended and doesn't have a menu item.
This is Visual Studio 2015 with Resharper Ultimate trial
The following steps worked for me:
Disable ReSharper
In ReSharper's options -> Keyboard & Menus, select the Visual Studio scheme and click on Apply Scheme.
Mind the note under the Apply Scheme button: Click save to close the ReSharper Dialog and...
In TOOLS --> Options | Keyboard, make sure the right mapping scheme is selected (Visual C# 2005 for me) and click Reset and finally, Ok
That did the trick for me. opening the keyboard dialog once again and hitting Ctrl+, in the Press shortcut keys was no longer showing the key mapping to be bound to Resharper.Resharper_GotoRecentEdits
As per my comment on the initial post - it seems sometimes you have to uninstall ReSharper to remove the key bindings.

How to enable C-U/C-D with ReSharper installed

I have recently installed VsVim and ReSharper into VS 2010. The ReSharper hotkeys seem to override those of VsVim.
Is there a way to make VsVim commands higher priority than those of ReSharper?
More specifically, I would like Ctrl+U and Ctrl+D to work like in Vim.
When I press Ctrl+D the shortcut conflict window appears and there doesn't seem to be a PgDown option.
On the window in the image select Visual Studio. Then open a text file (.cs, .cshtml, whatever) and in the bottom right of the window is an "options" button to the far right of the vsVim cmd line you type into. Click the options button and you will get a list. It will say "Ctrl_D handle with" and your options will be Visual Studio or vsVim; just switch it. You can come back and undo it later. I have VS2010, Resharper and vsVim and don't have the issue, but it may also be a .vimrc config setting where you need to disable the msvim options.
You need to tell ReSharper that you want Visual Studio to handle those keyboard shortcuts instead of ReSharper (in the window you show in your question), and tell VsVim that you want it to handle them instead of Visual Studio.
In up-to-date versions of VsVim, you do this by going to Tools -> Options -> VsVim -> Keyboard (by "Tools" I mean the menu in the Visual Studio menu bar). There you can configure what you want VsVim to handle. There used to be an "Options" button at the end of Vim's status bar, as John's answer says, but that is no longer true.
I have CTRL-d and CTRL-u set up to scroll in my VsVim configuration so I can vouch for it working.

Resources