Assign code snippet to keyboard shortcut in Visual Studio

不打扰是莪最后的温柔 提交于 2019-12-03 01:27:55
buzznfrog

Type a < and then type your snippet shorcut(your XML file Name) and then press tab.

you can get more info from this link https://docs.microsoft.com/en-us/visualstudio/xml-tools/how-to-use-xml-snippets?view=vs-2017

for example i have a code snippet which i've set xml file name and its shortcut to flog

when i want to use it directly to my code i do like this:

<flog and press tab it Works.

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)

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