[Vs hacks] custom

Source: Internet
Author: User
[Vs hacks] custom

# Hack 24 custom shortcuts

VS has many keyboard configurations. In fact, many shortcut keys have been found in vs. However, in this article, we will learn how to create new shortcuts, and Edit Existing shortcuts. Vs contains many commands, only a small part of which defines the shortcut key. You can add or remove the shortcut key definition in the "options" window.

(1) Add custom shortcuts

Here, you will add a shortcut key for the "generate-> regenerate solution" command. First, open the option window through "tools-> options, select the subitem "keyboard" under the Environment folder ". You can use this interface to edit or create shortcuts.

Vs does not allow modification to the default keyboard ing scheme. Therefore, you must first save the current ing scheme as another new ing scheme name, and then edit the new scheme. (However, I didn't find this button in vs2005, and I don't know where to improve it ).

Find the command to be defined. You can find it from the list by typing a part of the name in "display command inclusion" and select it.

Then, determine the scope of the shortcut key. In the "new shortcut key used" drop-down list, select "Global". For some shortcut keys, you can apply them to a designer or editor (for example, you can set a shortcut key for ASP. net, which is valid only when the design view of the HTML editor is used ).

The last step is to determine which shortcut keys to use. This is a little troublesome because many shortcut keys are occupied. If they are occupied, the current occupied objects will be displayed below, if you click "allocate" and then click "OK", it will be allocated successfully and overwrite the command shortcut that used this shortcut key.

Vs supports key chords, which is a combination of multiple shortcut keys. For example, CTRL + k and CTRL + e can be used as one command, the two shortcut keys must be followed to trigger the command.

(2) hacking the hack (I don't know how to translate it. Maybe I can only talk about it. Let's not talk about it, huh, huh)

This section focuses on how to develop a new computer after you have worked hard to customize your own style shortcuts, how to migrate these custom settings to another computer. Here we use the vstweak auxiliary plug-in tool, but this tool is only available for vs2003, and vs2005 has not yet been found, so I don't need it, and I don't need to remember it here.

But here we introduce a manual method. I think it can be used for reference. It is relatively simple. To put it bluntly, just copy a few files. File Suffix: ". vsk ", which exists in the \ Documents and Settings \ Application Data \ Microsoft \ visualstudio \ 8.0 directory. I tried it in vs2005. By default, there is only one current. vsk file, but after you delete it, Vs will automatically create a new one. If you modify the keyboard ing, it will generate a new users. the vsk file may be the file.

In addition, I personally think vs2005 will definitely not ignore this. You should use the Wizard to complete this work by running the "tool-> Import and Export Settings" command, as long as the goal is reached, it is OK. :)

# Hack 25 custom menu and toolbar

We can allow vs to work as expected and migrate these work methods to other computers. Vs contains many menus and toolbar. Let's learn how to customize them.

(1) custom Toolbar

A. Modify the existing Toolbar

Move button: Very easy, that is, press the Alt key and drag the button, you can drag and drop between the toolbar or between different positions in the same toolbar;

Add or remove button: First click "tools-> Custom" or click the small arrow on the right of each toolbar, select add or remove button-> Custom, then, the "Custom" window is opened, and the operation is done in it. In fact, it is dragged and dragged. You can directly select a command and drag it from the custom window to the toolbar.

However, after being dragged up, there may be no icons. This is a good solution. You can copy other buttons and then edit them. Right-click the menu to find the details.

B. Add a new toolbar.

This operation is also carried out in the "Custom" window, which is very simple and needless to say.

(2) custom menu

Similar to the toolbar, Menu customization is performed on the "commands" page of the "Custom" window and is directly dragged.

(3) reset changes

Botch up [port] (due to inattention, carelessness, etc.) to make it worse

What can I do if I am self-defeating by being naughty? Vs also provides a way to save, that is, to reset to the initial state. How can this problem be solved? The procedure is as follows:

A. Turn off all open;
B. Open the vs command window;
C. Enter devenv/setup;
D. All toolbar and menu bar customization will be reset, and problems will be fixed.

(Note: I have performed n tests in vs2005. Practice has proved that this has not worked)

(4) hacking the hack

For these custom migration, that is, how can we bring it to another computer. In my opinion, vs2005 still uses the "tool-> Import and Export Settings" command to complete these tasks using the wizard. The following is a manual method:

To put it bluntly, it is just copying files. The file name is "cmdui. PRF ". For vs2005, the \ Documents and Settings \ Application Data \ Microsoft \ visualstudio \ 8.0 \ 2052 directory exists. I tried it in vs2005. No problem, but if you delete it, Vs will automatically create a new one.

So after my thinking and experiment, if you want to reset the menu and toolbar changes, you don't need to run the unused command "devenv/setup. delete the PRF file. Or I think you can select the "reset all settings" function in the Wizard window that is displayed in "Tools> Import and Export Settings", but I have not tried this.

# Hack 26 create a custom window layout

The vs window is like a project dashboard. You can create different la S and switch back and forth between them.

VS has some default window la s, such as the design mode window la S and debugging mode la S. Modifications to these window la s will not affect each other. Although vs includes some layout schemes, it does not provide the functions of creating layout and switching layout. But provide a power toy can complete these jobs, that is vswindowmanager, I find the version for vs2005, for: http://www.codeplex.com/Release/ProjectReleases.aspx? Projectname = vswindowmanager & releaseid = 543. The latest version is
Vs2005 version 1.2beta. Switch off vs during installation and open it after installation. Two more items are displayed in the "window" menu, and the toolbar "Windows Manager" is added ", the toolbar buttons correspond to the layout modes in "Apply window layout.

The two menu items are "save windows layout as" and "Apply window layout", which are easy to use. Just click "retry", that is, you can customize the mode before applying it.

(1) hacking the hack

For these custom migration, that is, how can we bring it to another computer. It is just copying an object. The file name is "devenv. XML ". For vs2005, the \ Documents and Settings \ Application Data \ Microsoft \ visualstudio \ 8.0 directory exists. I tried it in vs2005. Unfortunately, the file is not found.

 

# Hack 27 custom toolbox

The vs toolbox is the most common tool used to store controls and code segments. You can drag and drop them to the editor or code window.

(1) controls and toolbox

You can add controls to the toolbox. I operate in vs2005. in the toolbox, select a tab, right-click it, and select "select item". A window is displayed, contains one. the control list of netframework and a com list, select those that are not checked before, and click OK to add them to the current tab.

If no icon is provided for the added control, the system automatically allocates a small gear icon. If you do the control yourself, you can create a 16*16 bitmap and set it to an embedded resource, and the same name as your control.

(2) code snippet and toolbox

A toolbox is usually used to add and remove tabs and controls, but it can also be used to store common code segments. For example, the toolbox is a good place to store a piece of JavaScript code and call methods to obtain the connection string.

You can create a separate tab and name it, for example, "code segment". Then, select the code segment from the document window and drag it to the tab. Then, it is OK. You 'd better rename it, make a meaningful name. This rename will not affect the content of the Code segment. If necessary, drag it to the specified position in the document window.

(3) hacking the hack

I still want to talk about what to do if I change the computer, or copy a file, that is, "toolbox. TBD ", for vs2005, the location is at: \ Documents and Settings \ <username> \ Local Settings \ Application Data \ Microsoft \ visualstudio \ 8.0 \. Of course, if a custom control exists, the corresponding control assembly also needs to be copied.

Note: These are post-reading and partial translations. If you want to reprint them, please let me know. Thank you.

 

# Hack 28 package toolbox settings

If you want to publish the same toolbox settings to many machines, you can write a program to add custom components or code segments to the toolbox. The most important thing for team development is to write consistent code. It is helpful to ensure that the same component set and code segment are available.

The manual file copy method described in hack 27 is not necessarily good for the distribution toolbox settings. This method is a good solution for Mobile Personal configuration, but as a distribution method, it may overwrite the custom controls and code segments created by each developer.

So what should we do? In fact, you can use Visual Studio common enviroment object model to create a applet to add controls and code segments to each developer's system.

First create a Windows Forms project, and then create a pair of envdte. DLL Assembly references (it contains the objects we need to modify the vs Environment). It is called the common enviroment object model and can be used to modify various aspects of vs IDE.

This book says that when using envdte, the "call was rejected by the callee" error may frequently occur. This may occur frequently on slow machines due to timeout, but it will also pop up on Fast Running machines. In the downloaded code, it registers an ole message to avoid this error. If you want to run the code correctly in the book, you have to modify some content according to your vs installation.

To obtain the current DTE instance, it is not simple, because for vs2002 and vs2003, the DTE object is almost the same, we must obtain this class through progid, as shown below:

Type latestdte = type. gettypefromprogid ("visualstudio. dte.8.0 ");
Envdte. DTE Env = activator. createinstance (latestdte) as envdte. DTE;

You can use the following code to obtain the reference of the currently running vs instance:

Envdte. DTE = (DTE) Marshal. getactiveobject ("visualstudio. dte.8.0 ");

The DTE object can be used to modify many parts of. To access the Toolbox window, you need to access the vswindowkindtoolbox constant of the Windows Set of the DTE object, and then forcibly convert it to the Toolbox type:

// Get the Toolbox window
Window win = env. Windows. Item (constants. vswindowkindtoolbox );

// Get the toolbox from the window
Toolbox toolbox = (Toolbox) win. object;

There is nothing to pay attention to in the future. It's omitted ......

# Hack 29 added support for non-standard file extensions

In fact, this is to use the plug-in tool vstweak to add a non-standard extension, so that vs can treat it equally as its own child; or to leave a certain extension out of the door, however, the vstweak tool is not available for vs2005 at the moment, so it can only be stunned.

# Hack 30 registry skills

VS has some configuration items that you can only obtain through the registry. Using it may do a lot of things, but you must be careful.

The registry contains many vs settings. Some of these settings can be set through the "tools-> options" dialog box, some can be edited through the powertoys tool of Vs, and some can be edited by directly accessing the registry. Here we will learn how to modify, how to use an alternative registry, and how to migrate these settings between computers.

(1) Registry Settings

Vs stores most settings in the registry. The first location is HKEY_CURRENT_USER/software/Microsoft/visualstudio/8.0, saving the specific settings of the current user. These settings include various editors, external tools, source code control, and almost all settings through the tools> options window. The second location is HKEY_LOCAL_MACHINE/software/Microsoft/visualstudio/8.0. Compared with the previous location, the system configuration is saved here, which works for all users. For each item, I will not go here, so it will be over.

(2) Mobile Registry Settings

Moving the registry key is simple, but dangerous. It is best to move only the items you know. The method of moving is simple, that is, selecting, exporting, saving, and then importing in another place. If you do not use vs2005, you can only use the registry to move fonts, colors, and editor settings between systems. Unfortunately, vs2005 is used :)

(3) Use alternative registration items

We usually need to back up the Registry when modifying the registry, saving the trouble caused by accidental failures. vs also provides another method. You can switch the registration items used by. The method is to copy the current registered item, then tell vs to use it, and modify it as much as possible (to one's heart's content). If something goes wrong, you only need to switch back to the old registration item location. The procedure is as follows:

A. Save HKEY_LOCAL_MACHINE/software/Microsoft/visualstudio/8.0 everywhere as the. reg file.
B. Open it in the text editor and replace "\ 8.0" with "\ 8.0hacks"
C. Double-click the. reg file and load its content into the current registry. An additional "8.0hacks" item will be added ".

Be careful when you replace the second step. Do not replace the errors. Haha, there are too many contents. There are thousands of replacement items.

After the creation is complete, the next step is to tell vs to use it at startup and use the/rootsuffix switch to perform the switchover. Run the command: devenv.exe/rootsuffix hacks, this command allows vs to use the new registry key tree. Note that you should type hacks instead of 8.0 hacks, because hacks is the suffix you add to the current key.

When vs is turned on, if something goes wrong, it will not be switched on or off, and the original 8.0 registry key content will be used. After I tried it, the wizard for re-configuring the vs development environment will appear, which is the same as when the installation was successful, but an error will also pop up, the 8.0hacks registry key is automatically generated in the current user registry key.

# Hack 31
Save and move ide settings

When I see this section, I find that my previous views are correct, vs2005 does use the "tools-> Import and Export Settings" function to perfectly solve the previously mentioned setting and movement functions completed by manually copying files or using tools. Click this menu item to display the Wizard. You can complete the "save", "import", and "reset" functions.

It saves these settings as. A file with the suffix vssettings. This file is a mix of XML and binary data. The structure of this file is in the XML file format, but some node values are binary data and cannot be edited, some are plain text and are easy to edit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.