With Visual Studio for more than 5 years, it's time to make a memo for yourself. Each time into a new group for new computers, install their familiar environment and have to reconfigure, do not do some memo old will forget something. The tool is used well and the efficiency is doubled naturally.
1, Code snippet
In Visual Studio, you can add your own favorite snippets of code. Visual Studio also comes with a lot of default code snippets, such as tryf,for and so on. What I often need is a copy of the file's header and a code comment. Adding a method is simple.
Microsoft Documentation: Walkthrough: Creating a Code Snippet
Copyright Add Method: Visual Studio 2015 as an example
Found it
C:\Program Files (x86) \microsoft Visual Studio 14.0\common7\ide\itemtemplates\csharp\code\2052\class
C:\Program Files (x86) \microsoft Visual Studio 14.0\common7\ide\itemtemplatescache\csharp\code\2052\ The Class.cs file under Class
Code after adding a comment
// ************************************************ ***********************
// FileName: $ safeitemname $
// Description:
// Project:
// Author: $ username $
// Created: $ time $
// Copyright (c) $ year $ $ username $, 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 $
{
}
}
Note: Copy this file to another place for modification, and then use it to replace the original one. Remember to replace both, otherwise it will not take effect.
After adding a class to the project, the following annotations are automatically generated:
// ************************************************ ***********************
// FileName: Class3
// Description:
// Project:
// Author: NewBLife
// Created: 2016/3/20 22:32:58
// Copyright (c) 2016 NewBLife, All rights reserved.
// ************************************************ ***********************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MvvmDemo.Common
{
class Class3
{
}
}
Annotation code segment adding method:
Create a new xml file, add the following code, and save it as a snippet file. The shortcut key is: myregion.
<? xml version = "1.0" encoding = "utf-8"?>
<CodeSnippets xmlns = "http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format = "1.0.0">
<Header>
<Title> class region </ Title>
<Shortcut> myregion </ Shortcut>
<Description> Code snippet for class region </ Description>
<Author> NewBLife </ Author>
<SnippetTypes>
<SnippetType> Expansion </ SnippetType>
</ SnippetTypes>
</ Header>
<Snippet>
<Declarations>
<Literal Editable = "false">
<ID> classname </ ID>
<ToolTip> Class name </ ToolTip>
<Function> ClassName () </ Function>
<Default> ClassNamePlaceholder </ Default>
</ Literal>
</ Declarations>
<Code Language = "csharp">
<! [CDATA [
#region ======= member =========
#endregion
#region ======= attributes =========
#endregion
#region ======= Method =========
#endregion
#region ======= constructor =====
public $ classname $ ()
{
}
#endregion
]]>
</ Code>
</ Snippet>
</ CodeSnippet>
</ CodeSnippets>
Import code snippet
Enter myregion in the file, the following prompt appears
Press Tab twice to insert the following code:
public class Class1
{
#region ======= member =========
#endregion
#region ======= attributes =========
#endregion
#region ======= Method =========
#endregion
#region ======= constructor =====
public Class1 ()
{
}
#endregion
}
2. Simple summary of shortcut keys
New project: ctrl + left shift + N
New file: ctrl + N
Code: F7
Designer: shift + F7
Popup prompt: ctrl + J
Line positioning: ctrl + G
Quick positioning: ctrl +,
Quick search: ctrl + F
Quick replacement: ctrl + H
File search: ctrl + shift + F
File replacement: ctrl + shift + H
File shaping: ctrl + K, D
Even the document format: ctrl + E, D
Partial document format: ctrl + E, F
Select text to convert to uppercase: ctrl + shift + U
Select text to convert to lower case: ctrl + U
Note selection: ctrl + E, C
Deselect content annotation: ctrl + E, U
Indent: Tab
Reduction: shift + Tab
Rename: F2
Remove unnecessary using references: Ctrl +. The cursor must be on using
Class interface extraction: Ctrl +. The cursor must be on the class name
Delete horizontal blank: ctrl + E, \
View blank: ctrl + E, S
Move selected line up: alt + up arrow
Move selected line down: alt + down arrow
Encapsulated fields: ctrl + R, E
Delete parameters: ctrl + R, V
Reordering parameters: ctrl + R, O
Fold to definition: ctrl + M, O
Stop outline display: ctrl + M, P
Create bookmarks: ctrl + B, T
Enable bookmarks: ctrl + B, E
Delete bookmark: ctrl + B, C
Move to the next bookmark: ctrl + B, N
Move to the previous bookmark: ctrl + B, P
Window shortcuts
Object Browser: ctrl + W, J
Error list: ctrl + W, E
Output list: ctrl + W, O
Properties window: ctrl + W, P
Bookmark window: ctrl + W, B
Resource attempt: ctrl + W, R
Debug shortcut
Commissioning: F5
Generate solution: F6
Interrupt: shift + F5
Switch breakpoint: F9
Step by step: F10
Step by step: F11
Function breakpoint: ctrl + D, N
That's all for basic usage, and I can't remember any more.
3. Plugins
Productivity Power tools2015 is recommended here. The dotted line of the code block indicates that it supports many functions such as saving automatic format and using finishing.
Easy to identify the method of selecting files
Different methods for each method
Final effect:
That's basically it. To develop fast, the tools must be skilled.
Visual Studio common tips one: code segment + shortcut key + plug-in = efficiency