CodeSmith实用技巧(十五):使用快捷键
在CodeSmith中,以下几个快捷键有助于我们快速输入。
1.Ctrl + Shift + C
在空行上,按下Ctrl + Shift + C后将会录入一个代码块。
<% %>
2.Ctrl + Shift + Q
按下Ctrl + Shift + Q后录入一个脚本块。
<script runat="template">
</script>
</script>
3.Ctrl + Shift + V
对代码块反转,如有下面这样一行代码:
<% for(int i=0;i<10;i++){}%>
在两个大括号之间按下Ctrl + Shift + V后,将变成如下代码:
<% for(int i=0;i<10;i++){%> <%}%>
4.Ctrl + Shift + W
按下Ctrl + Shift + W后会录入一个输出的代码块:
<%= %>
注意:在使用快捷键的时候,如果想要把一段代码之间放在录入的标记中间,首先选中这些代码,再按下快捷键组合。比如我们有一段这样的代码,想把它放在<script>里面。
public enum CollectionTypeEnum
{
Vector,
HashTable,
SortedList
}
public override void Render(TextWriter writer)
{
StreamWriter fileWriter1 = new StreamWriter(@"C:\test1.cs", true);
this.Response.AddTextWriter(fileWriter1);
StreamWriter fileWriter2 = new StreamWriter(@"C:\test2.cs", true);
this.Response.AddTextWriter(fileWriter2);
base.Render(writer);
fileWriter1.Close();
fileWriter2.Close();
}
{
Vector,
HashTable,
SortedList
}
public override void Render(TextWriter writer)
{
StreamWriter fileWriter1 = new StreamWriter(@"C:\test1.cs", true);
this.Response.AddTextWriter(fileWriter1);
StreamWriter fileWriter2 = new StreamWriter(@"C:\test2.cs", true);
this.Response.AddTextWriter(fileWriter2);
base.Render(writer);
fileWriter1.Close();
fileWriter2.Close();
}
选中它,再按下Ctrl + Shift + Q后就会变成:
<script runat="template">
public enum CollectionTypeEnum
{
Vector,
HashTable,
SortedList
}
public override void Render(TextWriter writer)
{
StreamWriter fileWriter1 = new StreamWriter(@"C:\test1.cs", true);
this.Response.AddTextWriter(fileWriter1);
StreamWriter fileWriter2 = new StreamWriter(@"C:\test2.cs", true);
this.Response.AddTextWriter(fileWriter2);
base.Render(writer);
fileWriter1.Close();
fileWriter2.Close();
}
</script>
public enum CollectionTypeEnum
{
Vector,
HashTable,
SortedList
}
public override void Render(TextWriter writer)
{
StreamWriter fileWriter1 = new StreamWriter(@"C:\test1.cs", true);
this.Response.AddTextWriter(fileWriter1);
StreamWriter fileWriter2 = new StreamWriter(@"C:\test2.cs", true);
this.Response.AddTextWriter(fileWriter2);
base.Render(writer);
fileWriter1.Close();
fileWriter2.Close();
}
</script>
支持TerryLee的创业产品Worktile
Worktile,新一代简单好用、体验极致的团队协同、项目管理工具,让你和你的团队随时随地一起工作。完全免费,现在就去了解一下吧。
https://worktile.com
Worktile,新一代简单好用、体验极致的团队协同、项目管理工具,让你和你的团队随时随地一起工作。完全免费,现在就去了解一下吧。
https://worktile.com