[英]Shortcut to string in Visual Studio
When using Visual Studio console applications I often use the following line of code: 使用Visual Studio控制台应用程序时,我经常使用以下代码行:
Console.WriteLine("press [enter] to exit");
Is there a way of setting up a short-cut key in Visual Studio so that I don't need to type this every time? 有没有办法在Visual Studio中设置快捷键,这样我每次都不需要输入它?
There are probably other lines of code I regularly use for one reason or another that a short-cut feature would be beneficial. 由于某种原因我可能会经常使用其他代码行,因此快捷功能将是有益的。
You can define yourself a code snippet . 您可以自己定义代码段 。 Creating Our Own Snippets Using Visual Studio 2010 is a cool article for this.
创建我们自己的代码片段使用Visual Studio 2010是一篇很酷的文章。
For Console.Writeline()
method, write cw
and press Tab twice. 对于
Console.Writeline()
方法,写入cw
并按两次Tab键 。
Save this in (filename).snippet 将其保存在(文件名).snippet中
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>cwe</Title>
<Shortcut>cwe</Shortcut>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[Console.WriteLine("press [enter] to exit");]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Next choose tools-> code snippet manager... , click import, choose your file and add. 接下来选择tools-> code snippet manager ...,单击import,选择你的文件并添加。
Now if you type cwe
while you coding click Tab. 现在,如果您在编码时键入
cwe
,请单击Tab。
如果您经常需要使用Console.WriteLine()
,则可以键入c + w + Tab
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.