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

别等时光非礼了梦想. 提交于 2021-02-20 05:34:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!