visual-studiolanguageservice

How do I create a UI like the insert snippet one in a Visual Studio editor window


From inside the text editor window, I can right click and select "Insert Snippet..." and I am presented with a search box that I can type and find a snippet. Once selected, the editor window is updated with text from the snippet. How does this work? Can this be done from MEF or do I have to use the MPF and implement a language service? If someone could just point me in a direction, looking at the MSDN docs is a little overwhelming, it seems there are number of ways to handle any task (MEF, MPF, Implementing interfaces directly).


Solution

  • As far as I can tell, after digging through reflector code, this is an internal feature. You can add to the snippets, there is a whole process for installing your own snippets and registering a key word to invoke them but this has to be done statically. I see no way to alter the snippet list and provide your own snippet text at run time, which was my originally goal.