This is similar to How to move Visual Studio's 'My Code Snippets' folder to another drive?, but the answer there is quite old and does not seem to work any more; furthermore, the relevant paths appear to have changed.
I created a code snippet via the VS snippets manager. It worked, but I wanted to change the shortcut. I couldn't see a way to delete the individual snippet in their UI, so I deleted the folder as it contained just that snippet. I am now finding myself unable to create a folder for my C# snippets.
When I go to save the snippet, I now see this window. The only option obviously makes no sense, and doesn't work in any case:
I've tried the "add" button in their UI. I am sometimes able to add a folder that way.
But if I do, the import still fails:
Given that I deleted the folder where the snippets were formerly located, how can I get snippet import to work?
I finally got this to work by renaming the file to the same name as one of the snippets at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC#\Snippets\1033\Visual C#
I then moved the file to that location, giving admin permission when it asked. This seems frankly absurd. But it did work, for a while; at some point VS reset the snippet.
Related
I would like to perform an action upon opening a particular Visual Studio 15/17/19 solution.
I need to inform anyone who is about to work on the project that there are important notes (included in the project) that they should read first. Ideally it would be a pop up so as to be very obvious.
When googling I can only find solutions that involve Visual Studio extensions but I need something that does not rely on anyone else doing anything (e.g. installing the extension) - it needs to be something dependent only on the project itself.
I'm hoping for something that I can add in the .sln or .scproj file that VS will see when it loads the solution and take action, but anything that achieves the same purpose would be good.
I'd be grateful if someone is able to let me know how I can achieve this.
You've got an extension called Solution Open Pop Up supported on many versions of Visual Studio.
In the Overview tab there is a Features section where you can see a short example of how to use it. From the extension's website:
If a file called SolutionOpenPopUp.txt and/or ReadMe.txt exists in the root folder of the solution, the contents are shown in a pop-up when the solution is open.
Using vs 2017, I've got a solution with 20 projects in it, all C++, none of them that big.
On certain files in one project, intellisense goes extremely slow, or doesn't work at all.
When I select a class member variable name, it doesn't get highlighted. When I git f12, it will pop up the "Intellisense operation in progress..." dialog for 4-5 seconds and will eventually give me a reference in the header and the cpp file for the member variable, whereas usually, it will just go to one of them and not give me a list.
All other cpp and header files work fine, quick response and I get matching-variable highlighting.
The errors pane shows no errors from intellisense or the build. I have no idea what makes these few cpp files special that they don't work.
I've tried removing the project and adding it back, I've tried deleting the .vs directory.
I'm not sure what else to try.
Anybody have any ideas?
Thanks.
I've been used to Visual Studio Code semi-broken IntelliSense, where it only shows relevant methods in certain circumstances, but that one is driving me crazy. Every time I create a class, Visual Studio Code is able to find it. But once this class is deleted, it is STILL able to find it, even days after it's been deleted.
How do I fix that?
vscode stores intellisense informations in .BROWSE.VC.DB files. For some reasons I was able to find them in .vscode folder for some projects but not in others, even with default configuration. The location might have changed with recent versions. I found all .BROWSE.VC.DB in AppData\Roaming\Code\User\workspaceStorage. Deleted it and it worked.
I started a project from the DirectX and XAML template and made some small edits to the Direct3D-only portion of the project.
Now I get a number of errors in the xamltypeinfo.g.cpp file, stating that the Common::NavigationHelper class doesn't exist. Hovever I can validate that it's definitely a class included in the template, but it looks like whatever generated these files didn't include it.
I don't want to go messing around with generated files, and I haven't touched any of the XAML code at all in the template.
I created another project walking through the steps I had performed, and ran a diff on the two projects. The entire Common directory (and namespace, which included NavigationHelper) was unique to the original project.
I then remembered that at one point I had accidentally added a XAML page. I promptly removed it, which seems to have left these files included but they weren't included by another other file. Visual Studio still generated references to them, thus the errors.
It looks like if you add any XAML pages that require navigation, pulling them out is not as simple as removing the file. You must also remove the navigation infrastructure as well, by removing all references to the Common folder that were added to your project.
This may be a duplicate, but I haven't found anything that answers it thus far. My company passed a resolution that all files need to have a boilerplate comment header, with file name and copyright date among other things. I was hoping there would be an easy way to just create a header template that is added to the top of every new class (.cpp and .h files) added to the project with a couple of variables that are replaced based on the date, file name, etc.
Unfortunately, it seems like this is a much larger task that it seems it should be. I've looked into Manipulating Code using the Visual C++ Code Model and Manually Creating an Item Template and can't seem to get any of them to do what I want.
Sorry if this sounds like a "do my work for me" post, but to me this just isn't worth spending that much time on. If it's going to take a day to figure out the subtleties of extending Visual Studio, I can just manually add and edit the header for each new file, as it isn't done that often. Is there an easier method than those I was looking at, or a simple example on how to utilize those methods for my purpose?
This may not get you any further than you have already got, but Simon is close in that you can create C++ file templates in the way that he suggests, but the path to the C++ templates is C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcprojectitems (note that on 32-bit machine it will just be Program Files).
If you edit the file NewC++File.cpp, the next time you add a new C++ file to a project your template will be used. Alternatively you can create your own files in this folder and they will appear in the Add New Item dialog.
This won't solve your problem around inserting the current date in the header (assuming you want that to be automatically determined), but you could update the template that you're using once a year, and that would be slightly less of a chore.
HTH
What you are looking for is called : Code Snippets
I personnaly use the snippets provided into VAssistX but it's a shareware so it's might not be a good solution for your company.
By the way if you are developing application on Visual C++ without VAssistX you are wasting a lot of time ;)
There is also a code snippets manager into Visual Studio, i never used it but i found some documentation on google :
http://msdn.microsoft.com/en-us/library/d60kx75h(VS.80).aspx
and
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/01/17/how-to-write-your-own-code-snippets.aspx
I hope it's will be helpfull.
Update: Unfortunately, the C++ templates do not work in the same way.
I have left the text below as a reference to anyone who finds this, but it only works for C#/VB.
You can definitely edit the class template for C# (we have done it for exactly the same reason as you - to include a standard header), I would assume you can do it for C++ too.
Check out these two directories:
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\"
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\"
Somewhere in each of those directories will be a class template folder. For C# it's in a zip file here:
...\ItemTemplates\CSharp\Code\1033\Class.zip
Extract the zip, edit the template to include your header and re-zip it. You will also then need to place an unzipped copy under the ItemTemplatesCache folder, (following the same path - ...\ItemTemplatesCache\CSharp\Code\1033\Class)
There are more details here.
(Sorry, I'm on my Linux PC now so I can't check if these paths exist for C++. If you get it to work, post the correct C++ paths back here, and I'll update this answer to reference them)