Visual Studio skills

Source: Internet
Author: User

Although Visual Studio is used every day, you may not know how to use some functions or even whether it is used. The following tips may help you.

First go to the directory:

Section 1:

How to add copyright information to your code.
How to add code segments to your code.
How to Use the task manager.
How to use the website publishing function.
How to put common code into the general options in the toolbox.
How to view the same document in multiple windows.
How to create a region to facilitate code reading and maintenance?
How to Create a rectangle selection area?

The following is a detailed explanation:

1. How to add copyright information to the code.

Writing code often requires writing some copyright information or some common namespace references. It is really troublesome to copy and paste each page. What can we do once and for all? The template function in vs can help us achieve this goal.

Solution: directly add D: \ Program Files \ Microsoft Visual Studio 8 \ common7 \ ide \ itemtemplates folder copy the corresponding template compressed package to the corresponding location in My Documents \ Visual Studio 2005 \ templates on drive C, then modify the information you want to add. Then, when adding a new item, select the item under "My template.

As follows:


1 // ============================================== ======================================
2 // Add copyright information
3 // copyright (c) $ year $ ARTM
4 // All Rights Reserved
5
6 // filename: $ safeitemrootname $
7 // created by Qiu Feng at $ time $
8 // description:
9 // ============================================== ======================================
10 using system;
11 using system. Data;
12 using system. configuration;
13 using system. collections;
14 using system. Web;
15 using system. Web. Security;
16 using system. Web. UI;
17 using system. Web. UI. webcontrols;
18 using system. Web. UI. webcontrols. webparts;
19 using system. Web. UI. htmlcontrols;
20 // Add a common namespace reference
21 using COM. artmctc. Mis. Common;
22 using COM. artmctc. Mis. model;
23 using COM. artmctc. Mis. Service;
24 namespace $ rootnamespace $
25 {
26 public partial class $ classname $: system. Web. UI. Page
27 {
28 protected void page_load (Object sender, eventargs E)
29 {
30
31}
32}
33}
34

 

Note: the website template and web application template are different.

2. How to add a code segment to the code?

During the coding process, some common code results are often used repeatedly. Is there a way to nest the code into vs ide?

Solution: No problem at all. Using the snippet file can solve this problem well. Open \ Program Files \ Microsoft Visual Studio 8 \ Vc # \ snippets \ 2052 \ Visual C #. There are many snippet files that come with vs. You just need to copy them, modify it to your own code segment.

See the figure below:

The Code is as follows:


1 <? XML version = "1.0" encoding = "UTF-8"?>
2 <codesnippets xmlns = "http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
3 <codesnippet format = "1.0.0">
4 5 <title> try-catch-finall </title>
6 <shortcut> trycf </shortcut>
7 <description> try catch finall code segment </description>
8 <author> Qiu Feng </author>
9 <snippettypes>
10 <snippettype> expansion </snippettype>
11 <snippettype> surroundswith </snippettype>
12 </snippettypes>
13 14 <snippet>
15 <code language = "CSHARP">
16 <! [CDATA [try
17 {
18 $ end $
19}
20 catch (exception exp)
21 {
22
23}
24 finally
25 {
26
27}
28]>
29 </code>
30 </snippet>
31 </codesnippet>
32 </codesnippets>
33

 

Usage:

For example, find the alias of the code segment you set, enter the Enter key, and then enter the tab key to automatically generate the following code:

 

3. How to Use the task manager?

If the project we developed is large and some code in the project is not complete, we can mark it for future search.

The task manager in vs can solve this problem very well. Usage: Enter: // todo: Content in the place where you want to mark, then, open the list of all tasks in view-task list.

4. How can I use the website publishing function?

When we deploy a web application. CS and other files because dll has been generated, it is useless to deploy the site. Generally, these useless files are deleted manually, is there a quicker way to do this? The release function provided by Vs can solve this problem well.

Select project -- Right-click Properties -- publish (publish) or select build -- publish to open the following dialog box:

5. How can I quickly and conveniently use common backup code next time?

During the coding process, we often write some repeated code. How can we back up the code and quickly call it next time?

The common options in the toolbox can achieve this function. Drag and Drop the commonly used code to the commonly used tabs in the toolbox, and double-click it next time. For example:

6. How can I view different parts of a document in the same window?

See the figure below:

After dragging, see:

Have you seen it? A document is divided into two! You can view both the header and tail of this document in a window.

How can we restore the past? Drag the small entry and restore the original entry.

7. How to create a region to facilitate code reading and maintenance?

Add

# Region

// Code area

# Endregion

8. How to Create a rectangular selection area?

Sometimes we only want to copy the first few columns of a piece of code, and the last few columns do not want to copy. How can this effect be achieved?

Very easy. Just hold down the Alt key and drag the mouse. The effect is as follows:

How to use bookmarks?
How can I use an instant window to display variables or execution methods?
How to quickly find files in the project on the hard disk?
How can I quickly adjust the format of a document or code segment?
How can I add files to a project quickly?
How to force smart prompts?
How to force call parameter information?
How to jump to a specified row?

How do I use the forward and backward positioning shortcuts?
How can I quickly switch between unused pages?
How can I quickly hide or display the current code segment?
How can I modify attributes of multiple controls at the same time?
How to record and play temporary Macros?

 

9. How can I use bookmarks to quickly find my own files?

If you are developing a medium or large project, if your solution contains many projects, and if you have many pages, it is difficult to quickly find a desired page, find directories at different layers? It's too slow. What's more, let's ask you to find a piece of code on a page ?!

The bookmarks in vs can solve this problem well. First, place the cursor in the Code where the bookmarks are to be marked, and then click the insert bookmarks button in vs to complete the bookmarking setting operation. You can also use the shortcut keys Ctrl + B and CTRL + T to set or cancel bookmarks.

See the figure below:

After the bookmarks are set, double-click the bookmarks you set in the bookmarks list to directly jump to the desired code segment. Remind me that you can rename the name of the bookmarks by yourself. It is very convenient.

10. How can I use an instant window to debug a program?

The purpose of this real-time window is needless to say. Everyone may know, but many people cannot find it when they accidentally close the window and try to use it.

Think about it. Since it is a real-time window that must be useful during debugging, how can we open it? Debug -- window -- instant window, or shortcut key: Ctrl + D, I

11. How to quickly find files in the project on the hard disk?

If you are using Vs and want to copy a file in the project, do not go deep into a directory in the hard disk and open the file in, right-click the option to open the folder, as shown in the following figure:

12. How can I quickly adjust the format of a document or code segment?

Now everyone writes code and copies it. But sometimes the copied code is not formatted as correct and neatly formatted as it is. How can this problem be solved? Adjust manually one line at a time? No!

Let vs do this boring job: select Edit> advanced> set the document format or edit> advanced> set the format of the selected code. With it, you are no longer afraid of poor code formatting.

13. How to quickly add files to the project?

Open Vs and paste the file to the folder you want to place.

14. How to force smart prompts?

Without vs, we can only remind you that many people will not write code. However, smart reminders do not allow us to use them as we like. After that, you cannot move the mouse any more, sometimes we have to delete some of the original code and click ". "To call smart notifications.

In fact, VS has a shortcut key that allows us to see what we want and when we want to see smart reminders.

Place the cursor where you want to call the smart reminder, and enter Ctrl + J. You can see that the familiar smart reminder is coming again. See the figure below:

15. How to forcibly call parameter information?

The parameter information of a method is also very important, but it sometimes causes the same confusion as 14. How can we "see what we want?

Remember this shortcut key: Ctrl + shif + space. Place the cursor over the parameter name, and enter Ctrl + shif + space to see what is going on:

16. How to jump to a specified row?

You can use either of the following methods to quickly locate a line in the document: 1. CTRL + G 2. Click the line number in the status bar, for example:

17. How can I use the forward and backward positioning shortcuts?

I believe that everyone in Vs will like to use "to definition", but how can we quickly return to definition after definition conversion? The shortcut key below will save you the time for "turning back:

CTRL + _. If you want to go back to definition, just enter Ctrl + shif +. Switch back and forth.

If you are too tired to look at it like this, you can use a more concise method: Open the view-Code definition window, and then point your mouse to a method on the page, see what is displayed in the Code definition window:

18. How can I quickly switch between unused pages?

You can switch the shortcut keys of different windows in window: Alt + TAB, so there are also: Ctrl + tab in vs to see the effect:


19. How to quickly hide or display the current code segment?

CTRL + M, m
20. How can I modify attributes of multiple controls at the same time?

Select multiple controls and right-click the attributes. The common attributes of these controls will appear. After modification, all the controls will change.
21. How to record and play a temporary macro?

If you need to repeatedly repeat a series of keyboard operations in Vs, you can consider letting vs write code on its own. Use the macro function in vs to record a series of keyboard operations that need to be repeated, and then directly execute the macro to allow vs to write its own code.

Recording: Tools-macros-record temporary macros, CTRL + shif + R
Play: tool-macro-run temporary macro, CTRL + shif + P
Save: tool-macro-Save the temporary macro. You can rename the macro.

Link: http://www.cnblogs.com/qqflying/archive/2008/11/24/1337489.html

Related Article

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.