When using Visual Studio console applications I often use the following line of code:
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?
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.
For Console.Writeline()
method, write cw
and press Tab twice.
Save this in (filename).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.
Now if you type cwe
while you coding click Tab.
如果您经常需要使用Console.WriteLine()
,则可以键入c + w + Tab
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.