Visual Studio skills GET, Visual Studio
- Common shortcut keys
- Automatically generate header comments
- Code snippet
- NuGet
- Team Foundation
Common VS shortcut keys
In general, we can directly see some functional shortcut keys in the menu. In addition, you can view and set shortcut keys for corresponding functions on the menu bar-tools-options-environment-keyboard.
- I recommend several commonly used shortcut keys.
I use VS2015 community edition, so there may be some shortcut keys that may differ from other versions.
Ctrl + K, Ctrl + U |
Uncomment the selected row or the row where the cursor is located |
Ctrl + K, Ctrl + D |
Align all codes correctly |
Ctrl + R, Ctrl + R |
Rename |
Ctrl + K, Ctrl + S |
Insert external code |
Ctrl +. |
Quick operation or reconstruction (universal key !!!) |
Ctrl + Delete |
Delete all words on the right of the cursor |
Ctrl + X |
Cut or delete the row where the selected code or cursor is located |
Ctrl + L |
Cut or delete the row where the selected code or cursor is located |
Ctrl + G |
Jump to line number or line |
Ctrl + Enter |
Insert null rows in the current row |
Ctrl + Shift + Enter |
Insert a blank row under the current row |
Ctrl + Shift + Space key |
Code prompt (view function parameters or something is most useful) |
Alt + arrow (↓, ↓) |
Move up or move down the row or selected code of the cursor |
Shift + F12 |
Search for all references |
F12 |
Jump to definition |
F9 |
Set or delete a breakpoint |
Automatically generate header comments
There are two common methods: modify template files and edit macro commands, therefore, we recommend that you use the template modification method. You only need to add the program file once and then generate it automatically.
First, find the VS installation directory, and find Common7 \ IDE \ ItemTemplatesCache in sequence. Note that it is ItemTemplatesCache instead of ItemTemplates. Although both directories can be used, files in the ItemTemplates directory cannot be restored once modified.
If you are using C #, you can open the file from the ItemTemplatesCache folder in sequence, and then edit the template file.
using System;using System.Collections.Generic;$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;$endif$using System.Text;$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;$endif$namespace $rootnamespace${ class $safeitemrootname$ { }}
Template file after adding a comment
// =============================================================================== // Author : HelloC// Email : yangjianping@sdyinfang.com// Create Time : $time$// Update Time : $time$// =============================================================================== // CLR Version : $clrversion$// Class Version : v1.0.0.0// Class Description : // ===============================================================================// Copyright ©YJP $year$ . All rights reserved.// ===============================================================================using System;using System.Collections.Generic;$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;$endif$using System.Text;$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;$endif$namespace $rootnamespace${ class $safeitemrootname$ { }}
After the configuration is complete, we can add a class file to check the effect!
The following are common template configuration variables:
$ Time $ |
Time |
$ Year $ |
Year |
$ Userdomain $ |
Current User Domain |
$ Username $ |
Current User Name |
$ Clrversion $ |
CLR version |
$ Machinename $ |
Computer Name |
$ Safeitemname $ |
File Name |
$ Rootnamespace $ |
Namespace |
Code snippet
What is a code segment? When you write a for loop, do you only need to break the for letters and press the "Tab" key? VS automatically generates the for loop code; if you want to press the "Tab" key to generate a piece of code, you need to use the VS code snippet function.
First, you can find "code snippet manager" (shortcut key: Ctr + K, Ctrl + B) in the tool menu. Here you can view all the built-in code segments provided by.
You can open any built-in code snippet file through the file path, write your own code snippet file according to the file content, and save the file as the extension. the snippet file, and the file name should not be repeated.
After writing the Code snippet file, you can directly import your Code to the corresponding folder (My Code Snippets) through the Code snippet manager.
After the import is complete, you can try it in the editing area. If you enter no letters, restart.
NuGet
Everyone is using it every day, so I will not repeat it again. Click it → NuGet has already been used
Team Foundation
Team Foundation Microsoft's own code version control tool, because the company unified SVN, so did not officially use this function, just click to experience the next
Visual Studio *** the first IDE in the universe, which is usually used by NLP. If you have any unknown and practical VS skills, you may wish to see them.