none
C# Code completion macros: where to find them. VS2013

    Question

  • Macros may not be the right name. If you type fore and tab you will get a structure for a foreach loop. I want to add a few of my own and figure looking at some examples will help. I did it in VS2008 a looong time ago, and don't remember what I did.

    Also how to add them once I have created them, since I remember so little about it.

    Thanks,

    Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't


    • Edited by Jon Q Jacobs Friday, December 16, 2016 1:17 PM
    • Moved by CoolDadTxMVP Friday, December 16, 2016 2:58 PM VS related
    Friday, December 16, 2016 1:17 PM

Answers

  • These are code snippets and you can create your own although the implementation isn't that complex. To see an example of a code snippet go to <VisualStudioDirectory>\VC#\Snippets\1033. The folders have various snippets. The snippet documentation is available here.

    To create your own use a text editor to create your .snippet file. Your snippets are (by default) stored under <Documents>\Visual Studio 2015\Code Snippets\Visual C#\My Code Snippets. You can create subfolders as well.

    After you've created snippets you need to import the folder structure (if you are using folders) by going to VS, Tools\Code Snippet Manager, select your Language and then use Import to import the folder containing your snippets.

    If you need to do anything more complex then you'll need to switch to third party. CodeRush for Roslyn has a very powerful, extensible templating engine that I personally use.

    Michael Taylor
    http://www.michaeltaylorp3.net

    • Marked as answer by Jon Q Jacobs Friday, December 16, 2016 3:50 PM
    Friday, December 16, 2016 2:58 PM

All replies

  • These are code snippets and you can create your own although the implementation isn't that complex. To see an example of a code snippet go to <VisualStudioDirectory>\VC#\Snippets\1033. The folders have various snippets. The snippet documentation is available here.

    To create your own use a text editor to create your .snippet file. Your snippets are (by default) stored under <Documents>\Visual Studio 2015\Code Snippets\Visual C#\My Code Snippets. You can create subfolders as well.

    After you've created snippets you need to import the folder structure (if you are using folders) by going to VS, Tools\Code Snippet Manager, select your Language and then use Import to import the folder containing your snippets.

    If you need to do anything more complex then you'll need to switch to third party. CodeRush for Roslyn has a very powerful, extensible templating engine that I personally use.

    Michael Taylor
    http://www.michaeltaylorp3.net

    • Marked as answer by Jon Q Jacobs Friday, December 16, 2016 3:50 PM
    Friday, December 16, 2016 2:58 PM
  • >code snippets
    That's the term I was trying to remember.

    >Tools\Code Snippet Manager
    Excellent!

    Thank you so much.

    Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't

    Friday, December 16, 2016 3:53 PM