Several common shortcut keys without mouse
F7 |
Switch between the design view and Code view. |
F9 |
Switch the breakpoint. |
F12 |
To variables, objects, or function definitions. |
CTRL + Shift + 7 CTRL + Shift + 8 |
Quickly navigate forward and backward in the "go to definition" stack. |
Shift + F12 |
Searches for all references to a function or variable. |
CTRL + M, CTRL + m |
Expand and collapse the code segment structure in the editor. |
CTRL + k, CTRL + c CTRL + k, CTRL + u |
Used to add and cancel comments to and from the code line. |
Shift + ALT + enter |
Switch between full screen mode and Normal Mode |
CTRL + I |
Progressive search. |
|
|
| Tool window |
|
| View. Class View |
CTRL + Shift + C (LASS) |
| View. Command window |
CTRL + ALT + |
| View. Document outline |
CTRL + ALT + T (EXT) |
| View. favorites |
CTRL + ALT + f (avourite) |
| View. Output |
CTRL + ALT + O (utput) |
| View. Attribute window |
F4 |
| View. Attribute page |
Shift + F4 |
| View. resource view |
CTRL + Shift + E |
| View. Server Resource Manager |
CTRL + ALT + S (ource) |
| View. display web browsers |
CTRL + ALT + R |
| View. Solution Resource Manager |
CTRL + ALT + L |
| View. Task List |
CTRL + ALT + k |
| View. toolbox |
CTRL + ALT + x |
|
|
| Project |
|
| Generate. Generate Solution |
F6 |
| File. add new items |
CTRL + Shift + |
| File. New File |
CTRL + n |
| File. Create a project |
CTRL + Shift + n |
| File. open the file |
CTRL + O |
| File. Open the project |
CTRL + Shift + O |
| Project. Rewrite |
CTRL + ALT + insert |
|
|
| Edit |
|
| Edit. Open new row |
CTRL + enter |
| Edit. Open a new row |
CTRL + Shift + enter |
|
|
|
|
Code segment
Open the code snippet intelliisenseTab
Open the code snippet selection windowCTRL + k, CTRL + x
Create custom code
Step 1: Create an XML file. Each code segment is contained in an XML file. In Visual Studio, you only need to go to "file"> "new..."> "file...", and then select the "XML file" type. Segment
Step 2: Define a code segment. If you are interested, you may even have a code segment that can be created. As long as you press Ctrl + k, CTRL + X on the second line of the file and select the "snippet" code segment, a template of the code segment file will be automatically inserted for you.
The title, author, shortcut, and Description fields are self-explanatory and I will not elaborate on them. The content in the <snippet> label is worth discussing. The following example provides the best explanation for this.
In fact, you put all the code in <! [CDATA [...]> label, which is inside the </code> label. For fields that you want to easily replace, you can place a "$" character on both sides of these fields. In my example, I set three parameters that can be easily replaced by my code snippet users: strmreader, filepath, and line. These three parameters are used internally in the CDATA section. Each parameter has a "$" character on both sides. In addition, each parameter must be defined in the <declarations> element. Specify an ID and a default value for each parameter (optional ).
A keen reader will notice that there is another parameter I have not defined in my code segment: $ end $. This is a special parameter used to specify the position of the cursor when you fill in the content in the code segment field and press Enter. There is also a special parameter that I do not list here: $ selected $. $ Selected $ the parameter is only valid for surroundswith code segments. It defines the placement location of the selected code segment when "surround with..." is inserted.
<? XML version = "1.0" encoding = "UTF-8"?>
<Codesnippet format = "1.0.0" xmlns = "http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title> File Processing </title>
<Author> James Lau </author>
<Shortcut> FP </shortcut>
<Description> opens a file, does some processing, and then closes the file. </description>
<Snippettypes>
<Snippettype> surroundswith </snippettype>
<Snippettype> expansion </snippettype>
</Snippettypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID> strmreader </ID>
<Default> strmreader </default>
</Literal>
<Literal>
<ID> filepath </ID>
<Default> fpath </default>
</Literal>
<Literal>
<ID> line </ID>
<Default> strline </default>
</Literal>
</Declarations>
<Code language = "CSHARP">
<! [CDATA [
Streamreader $ strmreader $ = NULL;
Try
{
$ Strmreader $ = new streamreader ($ filepath $ );
String $ line $;
While ($ line $ = $ strmreader $. Readline ())! = NULL)
{
// Perform some processing
$ Selected $
$ End $
}
}
Catch (ioexception ioex)
{
// Handle exception
}
Finally
{
$ Strmreader $. Close ();
}
]>
</Code>
</Snippet>
</Codesnippet>
Step 3: copy to the code segment placement directory
For example, it is placed under c: \ Documents ents and Settings \ Administrator \ My Documents ents \ Visual Studio 2005 \ code snippets.
Team settings
In Visual Studio 2005, another new feature that is rarely known is "Team Settings ". If you work in a team environment (in most cases), "Team Settings" can help you enforce team coding rules or Set Visual Studio faster.
Let's assume that you want to enforce a set of basic code format rules within the team. You can create only the setting file so that your team members can point to the file without specifying the content of these rules and allowing each team member to customize their ide options to follow these rules. Whenever you update the team settings file, the file will be automatically imported when you start Visual Studio next time to rewrite the existing settings. The following steps describe how to use this powerful feature.
Procedure1: Create a configuration file. You can use "Team Settings" to enforce any IDE custom settings you need. The most common setting for developers to use "Team Settings" should be code format settings. However, you can also use this function for any Visual Studio settings that can be exported, such as font and color, sourcesafe settings, keyboard shortcuts, and Menu customization. You only need to customize the required settings in Visual Studio, and then use "Tools"> "Import/Export settings..." to import them to a known location. Import only the group settings that you want to share with the team. This is important.
Procedure2: place the setting file in the UNC path. Copy the settings file exported in step 1 to the network path that your team members can access. On my computer, I shared my team settings files in the \ jameslau \ public \ teamsettings. settings path.
Procedure3: change the "Team Settings" Path. Ask team members to change their "Team Settings" path and point it to your team settings file. They can go to tools> options...> environment> Import and Export settings to complete this operation. Select the "use team settings file" check box to specify the path of the file set by the team.
/Resetuserdata Parameter
The last tip I want to share with you is related to the/resetuserdata parameter. If Visual Studio is corrupted at runtime and cannot be restored from the corrupt state, you can use this parameter to reset Visual Studio to its initial state. Examples of these problems may include: the window layout file is damaged, the menu custom file is damaged, or the keyboard shortcut file is damaged. Disclaimer: If this parameter is used, all environment settings and custom settings are lost. For this reason, Microsoft does not publicly support this parameter and does not make it public (if you type devenv.exe/? In the command prompt line /?, You will not see this parameter ). If you encounter environment problems, use this method as a last resort and make sure that you have backed up the parameter before using the export environment settings.
To use this parameter, perform the following operations:
1. |
Disable all Visual Studio 2005 instances. |
2. |
Click Start and select Run ...". |
3. |
Click "includevenv.exe/resetuserdata ". |
This command runs for several minutes, while Visual Studio clears the settings and resets itself to its initial state. In this case, you can open task manager to check whether the devenv.exe process is still running. After running, you can restart Visual Studio. The first startup dialog box appears again, just like running Visual Studio for the first time on a computer.