Skip to main content

All Questions

Tagged with
0 votes
1 answer
194 views

How to create custom snippets in Visual Studio 2022 for Blazor files (*.razor)

Is there a way that I can create my own custom snippets for Blazor files in Visual Studio 2022? I'm able to create custom snippets for C# using <Code Language="CSharp"> in the .snippet ...
bill_dom's user avatar
0 votes
2 answers
487 views

Is there a way to automatically import necessary NuGet packages, when using a snippet?

I've been trying to create some snippets and have not been able to find a way to automatically import NuGet packages when the user prompts the snippets. The documentation includes instructions on ...
Anders Hoffmann's user avatar
0 votes
1 answer
852 views

Visual Studio 2017 Suggestion List only showing Snippets

PROBLEM I'm on Windows 10 (November TH2 build) using Visual Studio 2017 v15.1.26403.7, and I'm not sure whether this problem happens in earlier releases but I noticed that the only way to show ...
ElektroStudios's user avatar
2 votes
1 answer
3k views

VB.Net snippets - get function or sub name

It would be very helpful if visual studio 2015/VB.net snippets are capable of getting the function name they're written in. For example a function like so: private function SomeFunctionA() as Boolean ...
Cal.B's user avatar
  • 88
7 votes
2 answers
4k views

Code snippet shortcut doesn't work everywhere

I have a code snippet string.Format(@"") with a shortcut sf that inserts the snippet and places the cursor in between the two double quotes. Really convenient. I can normally use it, of course, by ...
rory.ap's user avatar
  • 35.4k
12 votes
3 answers
2k views

Dynamic code snippet c# visual studio

I am working on a WinForms project with some repetitive tasks everyday. So I thought creating code a snippet will help me out, but it works for fixed code only. I want to dynamically create a code ...
Hot Cool Stud's user avatar
1 vote
1 answer
1k views

Usings and assembly references are not automatically imported from C# snippet

I'm trying to write a C# snippet with this content: ... <References> <Reference><Assembly>Microsoft.VisualBasic.dll</Assembly></Reference> </References> <...
ElektroStudios's user avatar
0 votes
1 answer
37 views

Missing code snippet "testc" after R# install

After installing R#8 on my Visual Studio 2013 Ultimate, I lost "testc" snippet. Rest of code snippets work fine, but this one in unrecognized. How can I turn it on again?
Jacek's user avatar
  • 12.1k
4 votes
1 answer
744 views

ClassName() did not return any, snippet tool visual studio 2013

I am trying to use snippet tool in visual studio to generate a copyright text in each file. I created a snippet file as follow: <?xml version="1.0" encoding="utf-8"?> <...
Jovirus's user avatar
  • 125
22 votes
2 answers
10k views

How to lower case a Visual Studio Code Snippet variable? [duplicate]

I've build some snippets to generate a fields for a setting class. I'm now using 2 variables - $setting$ and $Setting$ - to generate names for the property and the backing field. I like to use a ...
Kees C. Bakker's user avatar
0 votes
2 answers
5k views

Allow only 1 character in TextBox

I've coded a generic snippet to allow only 1 character in a TextBox in several ways, the code works pretty good but the thing is the code size has been quite extensive so I want to know suggestions or ...
ElektroStudios's user avatar
1 vote
1 answer
174 views

Can I use code snippets in a Visual Studio configuration file?

I'd like to prevent looking up a piece of configuration code every time I create a new application. Therefore I thought of using a code snippet, but I can't seem to find out how to use snippets in a ...
Herman Cordes's user avatar
18 votes
7 answers
39k views

Automatically create #region with same name at #endregion

I'm wondering if there is a way to make #region Some Region #endregion Some Region. If there is no way for doing it then maybe is it possible with Resharper? Hope it's clear what I'm trying to achive ...
Harry89pl's user avatar
  • 2,435
2 votes
3 answers
3k views

Shortcut to string in Visual Studio

When using Visual Studio console applications I often use the following line of code: Console.WriteLine("press [enter] to exit"); Is there a way of setting up a short-cut key in Visual Studio so that ...
whytheq's user avatar
  • 35.6k
0 votes
1 answer
246 views

Write some logic inside a .snippet file in C#

I am just curious if it is possible to write some logic inside a .snippet file or is there any work around to do something like that? For example: Read an xml file and based on that generate the ...
KasunLak's user avatar

15 30 50 per page