Tips for using vs. net
1, Comments, or repeatedCodeFragment
When writing code, we often need to write code comments. However, it is not annoying to write the comments in each class. If you copy and paste the comments every time, is it very troublesome, if we want to drag controls, it would be nice to drag them to the code file.VSIs possible, we just need to select our code block, and then drag this Code directly to the toolbox in code mode. Next, we can drag the "control" directly to our code where we want to comment. Is it cool!
2Format the entire block
We are writing code, or from someone else's Html Paste a section in the source file Html Code sticking to our VS In the design mode, is the format of the original mode unchanged? When writing code, VS We can arrange it in a very neat format for easy reading, but stick it VS In the design mode Html The Code cannot be guaranteed to have such a format, so that when we look for whether a mark is closed, it is all red and wavy lines, a special headache. Now there is a convenient way to make VS For us to do this typographical work, We can edit - Advanced - Click the format of the design document, then our code or Html the layout is neat. Shortcut Key: Ctrl + K + D
(HTML chaos)
after Ctrl + K + D
the current HTML Tag is sorted by layers! The same applies to CS Code
3Select a region
InVs. netBy pressingALTIn the left-side navigation pane. I wonder if you have selected a region like this? This technique allows you to create a region that does not contain rows (see figure). This method is very easy to copy, cut, and paste rectangular area blocks.
You may be surprised why someone needs this profound feature. In fact, I often use it to make a target search in a specific document section.-The replacement operation, but due to the regular automatic line feed option, I cannot do this. I believe you will find this feature very convenient.
4, Search for matching tags
Some identifiers are always paired. For example,{"Must use the corresponding"}. AlthoughVs2005You click{, Matched with him}It will be highlighted, but if the code is too long, it will be hard to find. Similarly, the compiler indicator"# Region"Must have a corresponding"# Endregion. When you navigate your code, you sometimes need to find the corresponding identifier. By pressingCTRL-]You can do this. This shortcut key takes effect only when the cursor is under any of these identifiers. It immediately jumps to the corresponding identifier regardless of whether it is an open or closed identifier.
If you want to highlight all the code between two matched identifiers, pressCTRL-shift-]The entire block is highlighted, and the cursor is moved to the opened logo. This shortcut key only works when the cursor is under any logo (for example, it does not work when the cursor is in the area ).
5. Definition of the redirection Method
When you see a method call of your class, you are very likely to look at the method body. In Vs. net . In the text editor, right-click the method name and select to define from the pop-up menu. Vs. net Jump to the definition of this method immediately. The default shortcut for this feature is F12.
6 , Practical pre-defined code snippets
Code snippets are popular and pre-defined text templates can be selected by developers rather than manually typed in. For example Foreach Loop, instead of all the code you need, you can simply Foreach . SMART awareness is displayed with a new code snippet icon Foreach Item (see figure ). If you select a piece of code from the smart sensing list, then press Tab , VS Will insert Foreach .
As friends in the garden constantly introduce some of their vs skills, this articleArticleWe are also constantly updating and here, thank you!
Update
7. Design view and code (CS) file Switch
We are adding. to switch to the background code in the aspx file, right-click the design view and select "view code". We can easily switch to the background code, you can also use the shortcut key F7 to switch between them.
8. custom string case-insensitive Switching
Maybe the title is not exactly named. It means that if we define a string like this:
String Strvalue = " Aaaaaaa " ;
What if we want to change this AAAAA to an uppercase aaaaaa? Delete the file in the rewrite? In fact, a convenient variable is to use Ctrl + Shift + U, which can only be converted to uppercase in lower case. If we convert uppercase to lower case, use Ctrl + U.
2007-10-31
9. Cut and copy the entire row
If we are cutting the entire row, how can we copy or cut it if it is not selected? We can move the cursor to the front of this line, and press Ctrl + X or Ctrl + C to copy and cut the entire line. (Also applies to pasting)
We hope that the above will make it easier for you to write code.