Save and restore code clippings in Visual Studio Toolbox - visual-studio

I occasionally give demos and training at my office. I have seen and used the technique where you drag code into the Visual Studio toolbox, so that you can later drag it into a code file during a demo.
My question:
I would like to be able to save and later reload tabs (each tab contains a demo/tutorial of code snips), so that I can get rid of clippings that I am not using, but still get them back.
Anyone know how to do that in Visual Studio? (using VS 2012 Professional)
Note: I have seen this article that describes where they are saved: Where does Visual Studio save code blocks that are dragged on the Toolbox
However, I am looking for a way to restore the snippets without restoring my entire set of vs settings.

If you still have the tool box options available in VS, in theory you can export just the toolbox contents through Tools > Import and Export Settings... and import them later.
On the Import and Export Settings Wizard, choose Export..., click Next >. In the Choose Settings to Export > Which settings do you want to export? list, clear everything and then navigate to General Settings > Toolbox and select it. Then click Next > and save the file where you want.
Afterwards you should be able to restore just the Toolbox settings by using the Tools > Import and Export Settings... dialog.
Note that after I did an import I didn't see the snippet in the Toolbox, using VS 2017 V15.2, until I shut VS down and re-started it.

Related

Make Visual Studio use VS code shortcut keys / key bindings

I've been using VSCode a lot lately and have gotten used to the keys-shortcuts/key-bindings (Ctrl+D, Ctrl+P, Alt+leftArrow, etc). However I've recently had some work where I needed to use regular Visual Studio (Microsoft Visual Studio Enterprise 2019) and it's painful remembering two different shortcut keys.
Is there a way to import VSCode key-shortcuts to into regular Visual Studio?
I've looked at this question and there wasn't much help besides manually changing them one at a time.
UPDATE: now the above post answers the question now that I posed Francois du Plessis's answer there.
If you go to Tools -> Options -> Environment -> Keyboard. There should be an option to select Visual Studio Code as a Keyboard mapping scheme
You can create your own settings file based on an existing Visual Studio file.
Simply add your settings to it from VSCode keybinding setting file.
VSCode's keybinding settings is stored in keybindings.json json-formated file.
open file in menu
File->Preferences->Keyboard Shortcuts
or on Windows file path like that
C:\Users\<user name>\AppData\Roaming\Code\..\keybindings.json
Visual Studio's keybinding settings is stored in CurrentSettings.vssettings xml-formated file.
on VS menu:
Tools->Import and Export Settings
then select 'Import select environment setting' radiobutton and click 'Next'
you'll see browser for import your file.
on Windows file path like that
C:\Users\<user name>\Documents\Visual Studio 2019\Settings\
You can read more about it at this:
Make Visual Studio use VS code shortcut keys/key bindings

Cannot import window layouts into VS2013 from VS2012

I'm having trouble importing window layouts from Visual Studio 2012 to Visual Studio 2013.
I'm getting this error message, when I try to import *.vssettings file exported from VS2012 to VS2013:
Your settings were imported, but there are some warnings.
Warning 1: Category 'Window Layouts'
({eb4ba109-a9db-4445-bd09-e7604bcdce84}) could not be migrated because
the author of the category did not provide support for migration.
I had same problem with importing window layouts from VS2010 to VS2012. I thought there was some kind of breaking change that prevented direct importing, so I just recreated my preferred window layout in VS2012.
So basically I have to recreate my preferred window layout once again in VS2013. Does anyone have any suggestion how to solve this?
By the way, I've tried to reset settings in VS2013 (Tools -> Import and Export Settings -> Reset all settings...) and then try import settings from VS2012, but no change.
Edit: what's weird, is that I can create a window layout in VS2013, export it, reset settings in VS and then import back settings with that window layout and the import is successful (imported window layout gets applied).
Does this mean Microsoft completely dropped support for migrating window layouts from one version of Visual Studio to another? I would understand, if the imported window layout contains layout information for non-existing windows (like VS2012 -> VS2010 import). But standard way of migrating settings (to newer version of software) should be supported, right?
It's a bug in the Visual Studio settings migration feature, the window layouts are actually directly compatible between VS2010/VS2012/VS2013. The solution is actually really easy: Manually export just the window layout from VS2010, change the version number in the file, then import it into VS2013, and it'll work.
For the step by step solution to this problem, do the following:
Open Visual Studio 2010
From the main menu, select "Tools->Import and Export Settings"
Select "Export selected environment settings" and press "Next"
Select only the "General Settings->Window Layouts" option from the settings tree, and press "Next"
Name the file how you want and select "Finish"
Open the exported settings file in a text editor, and change the second line from this:
<ApplicationIdentity version="10.0"/>
To this:
<ApplicationIdentity version="12.0"/>
Or set the version string to 11.0 for Visual Studio 2012.
Open Visual Studio 2013
From the main menu, select "Tools->Import and Export Settings"
Select "Import selected environment settings" and press "Next"
Save your current settings if desired, and press "Next"
Select "Browse" and locate the modified settings file, then press "Next"
Press "Finish"
I came across this question while searching for a solution myself. I couldn't find an answer anywhere, so hopefully this will help anyone else who comes across this problem.
EDIT: I've now seen a case with a colleague where there was something in his window layout settings that wasn't directly compatible with Visual Studio 2012, so this solution failed for him. If you get errors migrating your window layout, I'd suggest resorting to "slicing and dicing" the window layout to narrow down which part(s) are causing the error.

Share a custom made Visual Studio 2010 toolbar

I've created a new Toolbar in Visual Studio 2010 and added some custom buttons to it (mainly utilising the External commands).
I'd now like to share that toolbar with others, or be able to "save" it so that I could re-import at a later date.
I know that you can use the Import and Export Settings Wizard to back-up all your settings and re-import them elsewhere, but it does not allow you to Export a single toolbar instance.
Can anyone point me in the right direction of how I might be able to do this? I don't mind if it's just a settings file I have to save, a VS Extension I have to write, or an installer package I have to create - I'd just like to be able to share my toolbar!
I'm working in 2008, but in the Import Export Settings Wizard, limiting it to
General Settings > Menu and Command Bar Customizations
will narrow it down to just your toolbars.
The settings file is all just XML so you can look at stripping out your personal preferences and leaving just the elements of your custom toolbar.

Visual Studio 2010 IDE question

When I double click an item in the find window, the C/CPP file opens in a tab next to the find window. I want it open in the main window (center) along with the other c/cpp files. Is there a setting to get this behaviour ? Thanks
Perhaps that setting has been modified somewhere. I've tried to reproduce the behaviour in a new(ish) installation of Visual Studio 2010, and can't reproduce. Perhaps you've chosen the C++ Development Settings where the behavior is different from the C# Dev Settings.
Consider resetting your Visual Studio 2010 settings.
Tools -> Import and Export Settings -> Reset All Settings

How to Export/Import Toolbars in Visual Studio

I export my settings in Visual Studio and if I ever move to a new machine or have problems, I use those backed up settings to restore Visual Studio to the way I like it. It also allows me to maintain a consistent development environment between the various machines that I use.
This works great for keybindings, syntax highlighting, user tools, pretty much everything except for the toolbar locations and customizations. Whenever I move to a new machine and restore the settings, the toolbars are not affected. I have spent a fair amount of time setting up toolbars with my macros, external tools, etc and cut'n'pasted icons in for them. I hate losing all that work.
Does anybody know how to back up and restore the toolbars' locations and customizations? If it is not a feature of Visual Studio, is there an addin that will do the job?
Edit
As mentioned below, the Menu and Command Bar Customizations in Import and Export Settings is supposed to do this, but when I re-import my previous settings, I get
Error 1: Menu and Command Bar Customizations: The version of command bar settings being imported is not supported. All the command bar settings have been ignored.
The settings I am trying to re-import were exported earlier this month with the same version of Visual Studio. The only difference is that I am now running 64 bit as opposed to x86. I didn't think that would make a difference though since the settings files are XML.
Any ideas?
I have finally found the solution to this. There is a known bug in Visual Studio and there are two workarounds given. The first workaround does not apply, but the second worked.
To Backup your toolbars:
Copy the file CmdUI.PRF from the path %AppData%\Microsoft\VisualStudio\X.Y\1033 to the same directory as your exported .settings file.
where X.Y is either of 8.0, 9.0, 10.0 or 11.0 depending on your visual studio version (2005, 2008, 2010 and 2012 respectively).
To Restore your toolbars:
Make sure Visual Studio is closed and copy the backed up file back to the original location.
For the benefit of others, as you mentioned this feature doesn't seem to be supported across versions of Visual Studio, presumably because of a change in the DTD/XSD for the settings file? At any rate, here's where the settings for your custom toolbars lie in the "Import and Export Settings..." dialog:
Note: Your options may look different, depending on the settings you exported.
I have not tried it, but "Tools\Import and Export Settings..." maybe will let you export a .vssettings file you can then take to another box.
See also
http://blogs.msdn.com/saraford/archive/2005/04/19/409887.aspx
and other Sara 'export' tips.

Resources