问题
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?
回答1:
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}")
回答2:
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.
来源:https://stackoverflow.com/questions/31746690/visual-studio-2015-codelens-toggle-on-off-with-keyboard-shortcut