Add custom code snippet to visual studio intellisense - visual-studio-2010

There is this nice program that enable you to easily create code snippets. I already managed to create snippets but it will be nice if the snippet where to show up in visual studio's intellisense.
For example visual studio already has several built in code snippets such as the one for creating the constructor of a class:
note that it was really easy and fast to use it.
On the other hand when I create my custom snippet with the program that I provided on the first link, these are the steps that I have to do in order to use it:
on step 3 I have to select the folder where the snippet that I created is located then on step 4 locate it.
It will be nice if I could use the code snippet that I created just like the ones that visual studio provides like the constructor one that I showed on the first image. Maybe if I place the snippet that I just created and place it where visual studio store the built in onces it works.

I had to add a shortcut to the snippet.
after adding the shortcut it appears on the intellisense without having to navigate to the folder where it was located by pressing ctrl+k and ctrl+x

Related

Code-Snippet not refreshed in Visual-Studio

I am creating Code Snippet in Visual-Studio 2010 using "Snippet Editor". All is working fine when i first save the snippet in the folder ... Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets.
The snippet is executed when i do CTRL-K CTRL-X and choose it in the list, and also by intellissence using the snippet Shortcut.
My problem comes when i only change the code of the snippet and save it again :
the new code is executed when i hit CTRL-K CTRL-X
the old code is executed when using intellisense ??
the problem is still here when i reopen VS
I don't think this is a "Snippet Editor" issue. Is there any "Intelissence Cache" i would have to reset ?
I have the same issue in visual studio 2019.
I have a custom ( My Code ) snippet file with multiple CodeSnippet elements added with the Code Snippets Manager and recognized and working in visual studio.
I make two changes.
The first I add a comment to an existing CodeSnippet just to demo that the change has been recognized.
I then change the Shortcut element of another CodeSnippet and completely change the Code.
Import again with Code Snippets Manager and Overwrite.
Use both snippets.
The first now has the additional comment.
The second does not have the code that is in the CDATA of the Code element but has what was there before !
Put the two CodeSnippet elements in separate snippet files and all ok.
Seems to be a bug in Visual Studio 2010, no more problem on the next version of VS

Refactor menu missing from Visual Studio 2015

I am having trouble finding the right-click context menu in Visual Studio 2015. I know that nothing is wrong with my project or the file I am working. I can find the right-click context refactor menu in Visual Studio 2013. However, in Visual Studio 2015 there isn't a refactor context menu in the right-click context menu.
Where did it go? How do I get it back?
Your suggestion cannot include menu Edit → Refactor.
I have tried to reset my Visual Studio settings back to default using menu Tools → Import and Export Settings and that didn't bring the menu back either.
Some of the refactoring tools have been relocated or are at least accessible in a different manner than they were previously.
Using the extract method refactor as an example, you can still use this function; it is just not done the same as before:
Right click
Quick actions
Click extract Method
I think they've changed it to feel more "ReSharper"ey. All of the functionality should still be there however.
Here's more information on refactoring in Visual Studio 2015 - hopefully this helps! Refactoring (C#)
You no longer need to access the refactoring using the mouse right click.
It is recommended that you use the keyboard shortcut keys within Visual Studio.
For all possible shortcut keys, see Default Keyboard Shortcuts in Visual Studio, Refactor.
You might need to build the project to get it to work.
See Code Editing ASP.NET Web Forms in Visual Studio 2013 | Microsoft Docs. (If it is missing then the point is that I am using an example provided by Microsoft.). In Refactoring and Renaming see To extract a method in a C# page. When I follow the instructions I cannot find the feature to extract the code to a method. When I tried the Edit menu it said I did not have valid code. Then I built the project and the feature to extract the code was available and worked.
If you change the name of the object you are refactoring, the light bulb then appears to the left which asks if you wish to change the name of the object (i.e. refactor) or generate a new constructor for the new named object.
Ctrl + . is the shortcut key for extracting a method in Visual Studio 2015 and onward.
Ctrl+M, R does not work anymore in new versions.

How do you change the default programming language visual studio 2013?

I installed Visual Studio 2013 again after I got a new PC, but now when I create a new file it creates it as an VB file instead of c#.
I changed the default programming language in web.config like shown here:
I tried reloading the project but it still does not work.
The web project is placed on a local ftp server.
When you make a new project, under Templates you should see a node for Visual Basic and one for Visual C# with the different types of projects listed under the language. I believe VS remembers which one you used last.
The menu that shows up when you right click on a folder > "Add" shows a list of the options available for that folder ex. if you are in App_code it shows "Class". It seems it doesn't change the first suggestion to C# class even tho you change the programming language. So to fix that you go into the same menu and pick "Add New item..." and select C# Class file ...close it. Now if you try and create a file again it still says "Class" in the Add menu, but when you select it now, it creates it as an C#.
Sovled the problem for me. Thanks to all of you leading me to the answer.

How can I start new project from the Visual studio start menu?

In my Windows 7 Start menu, when I open the Visual Studio sub-menu, it shows my “pinned” projects and also my recently opened projects:
This is quite useful and can speed up opening the project a lot (because I can do something else while Visual Studio and the project are loading).
But I often happen to create new temporary projects (especially when answering SO questions). Is there some way to streamline this too? Ideally, I'd like to add a shortcut among the pinned projects that creates, say, a new C# console application. Can I somehow modify the menu to add such shortcut? Or is there something else that achieves similar effect?
Another option is to create a start-menu/taskbar shortcut to:
devenv.exe /command np
After clicking it you would need to choose the type and name for your project
You could also create a script that copies your template project and opens the new copy in VS.
I use a common test solution "test.sln" that I reference when I need to open visual studio to try out some code. I just open the test solution and add another method. Then in my Main method, I just call the new method added.
If you are constantly adding new test projects and you don't need to keep them around, you can use temporary projects.

How to insert code snippet for Debug.WriteLine(); in Visual Studio?

I can simply insert code snippet for the Console.WriteLine(); by just using the cw with Tab + Tab. But I'm not able to find the same option for the Debug.WriteLine();.
I want to know how can we customize the code snippet template in Visual Studio for Windows Phone?
In Visual Studio 2010 (and assuming other versions as well), there is not a snippet for Debug.WriteLine(). In that case, you'll need to create a custom snippet. Fortunately, it isn't that hard with the available resources:
MSDN: Creating and Using IntelliSense Code Snippets
The Snippet Editor
Snippet Designer (Visual Studio Extension) and the related CodePlex Site
If you're using ReSharper, then Code Templates and specifically Live Templates are a quick and easy option.

Resources