Assign code snippet to keyboard shortcut in Visual Studio

前端 未结 4 708
野趣味
野趣味 2021-02-02 10:33

Anyone knows how to assign key shortcut to specific code snippet?

I would like to assign for instance CTRL+K,CTRL+J to a #region snippet.

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-02 11:11

    The closest solution I've found for this is to copy the intended snippet to your local snippets directory.

    e.g. For VS-2015: %Userprofile%\Documents\Visual Studio 2015\Code Snippets\Visual C#\My Code Snippets

    Then open it in a text editor and change the shortcut to something quick and simple such as '1'.

    Now to use it, all you need to do is press Ctrl+K+S > Enter > 1 > Enter

    Additionally, you can make it even quicker by changing the hotkey for the surround-with command. (Tools > Options > Keyboard > Edit.SurroundWith)

提交回复
热议问题