Home

Custom Snippets

The Premium edition also enables your favorite Visual Studio code snippets, plus a dozen unique high-productivity LINQ snippets - as well as any custom snippets that you define:
Hi I´m new as in NEWbie.. Can anybody guide me to a simple step-by-step HowTo on the above statement. For a start I´d love a snippet shortcut "co" that inserts "Console.WriteLine("");" Thanks in advance and happy linqPadding.

Comments

  • LINQPad uses the same format for code snippets as Visual Studio. So any snippets that you define for Visual Studio will also work in LINQPad. Here's an example that does what you describe:
    <?xml version="1.0" encoding="utf-8" ?>
    
    	
    		

    co (Console.WriteLine)
    co
    Console.WriteLine

    Expansion


    Console.WriteLine ($end$);




    Change Coooode to Code ('Code' is a reserved tag in the forum software).

    Name this file co.snippet and put it in either in your Visual Studio snippets folder or in LINQPad's code snippets folder (go to Edit | Preferences to find out or change where this is).


    P.S. LINQPad already has a snippet called 'cw' for Console.WriteLine, just as in Visual Studio.
  • edited May 2013
    Works! Big thanks & most appreciated.
  • Unfortunately, the favorite Visual Studio Code snippets are only considered from VS 2012/2015/2017, but not 2019.
    With aid of Sysinternal's ProcessMonitor I found that LinqPad5 also reads a file %programFiles%\LinqPad\SnippetLocations.txt and I did add a line that points to My VS 2019 code snippets, but in vain.
    So to get my VS 2019 code snippets considered by LinqPad5, I had to copy them from folder %userprofile%\Documents\Visual Studio 2019\Visual C#\My code snippets to folder %userprofile%\Documents\Visual Studio 2015\Visual C#\My code snippets. This solved the problem but you have to synchronize these two folders time by time.

  • Fair point, VS2019 is picked up by LINQPad 6 but not LINQPad 5. I'll update LINQPad 5 to recognize the VS2019 folder as well.

Sign In or Register to comment.