Keyboard shortcut for C# Console Class
Save the following as a .snippet
and import it (used the cw snippet as a template)
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>cr</Title>
<Shortcut>cr</Shortcut>
<Description>Code snippet for Console.ReadLine</Description>
<Author>Whoever you want it to be</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>SystemConsole</ID>
<Function>SimpleTypeName(global::System.Console)</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[$SystemConsole$.ReadLine();]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Once imported, you can hit cr and tab twice to get Console.Readline();
There is no shortcut(code snippet) for Console.ReadLine()
. However you can create your own that.
Here is the snippet that I modified from the cw
:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>rl</Title>
<Shortcut>rl</Shortcut>
<Description>Code snippet for Console.ReadLine</Description>
<Author>Xiaoy312</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>input</ID>
<ToolTip>variable for console input</ToolTip>
<Default>input</Default>
</Literal>
<Literal Editable="false">
<ID>SystemConsole</ID>
<Function>SimpleTypeName(global::System.Console)</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[var $input$ = $SystemConsole$.ReadLine();$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Just drop it in your snippet folder. I put mine there :
C:\Users\Xiaoy\Documents\Visual Studio 2015\CodeSnippets\Visual C#\My Code Snippets\rl.snippet
When you type rl
and tab twice, you get this :
var input = Console.ReadLine();