visual studio-快捷键的使用

剪贴板功能

  1. 使用场景:连续复制多条内容时,通过剪贴板可以查看之前复制的内容,点击某条复制内容可粘贴。
  2. 快捷键:ctrl+shift+v

扩展选择范围&缩小选择范围

专业术语:extend/shrink selection

使用场景:在不通过拖动鼠标的情况下,通过连续按快捷键扩大/缩小想要选中的代码区域进行复制或删除操作。

快捷键:扩大:alt+shift+(加号)、缩小:alt+shift+(减号)

折叠/展开方法块

快捷键:折叠:ctrl+m+o、展开:ctrl+m+l

自动格式化代码

快捷键:先ctrl+k,后ctrl+d

自定义区域折叠代码块

使用场景:选中某块想要折叠的代码快,通过输入快捷键进行折叠。

快捷键:先ctrl+m,后ctrl+h

快速生成构造函数

快捷键:ctor + 回车键或者Tab键

public HomeController()
{
    
}

快速生成属性

快捷键:prop + 回车键或者Tab键

public int MyProperty { get; set; }

快速生成包含字段的属性代码

快捷键:propfull + 两次Tab键

private int myVar;

public int MyProperty
{
    get { return myVar; }
    set { myVar = value; }
}

快速生成依赖属性

快捷键:propdp + 两次Tab键

public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}

// Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(int), typeof(ownerclass), new PropertyMetadata(0));

快速生成附加属性

快捷键:propa + 两次Tab键

public static int GetMyProperty(DependencyObject obj)
{
    return (int)obj.GetValue(MyPropertyProperty);
}

public static void SetMyProperty(DependencyObject obj, int value)
{
    obj.SetValue(MyPropertyProperty, value);
}

// Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
    DependencyProperty.RegisterAttached("MyProperty", typeof(int), typeof(ownerclass), new PropertyMetadata(0));
posted @ 2024-12-20 18:14  相遇就是有缘  阅读(138)  评论(0)    收藏  举报