watbywbarif
watbywbarif

Reputation: 7017

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

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?

Upvotes: 26

Views: 5885

Answers (2)

balajikris
balajikris

Reputation: 301

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.

Upvotes: 8

Sergey Vlasov
Sergey Vlasov

Reputation: 27910

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}")

Upvotes: 22

Related Questions