Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard shortcut for C# Console Class

I know the shortcut for Console.WriteLine() is type cw and tab twice. Does anyone know what's the short cut for Console.ReadLine() ?

like image 780
anam Avatar asked Aug 26 '15 14:08

anam


People also ask

What is Alt C shortcut?

Alt+C is a keyboard shortcut most often used to view the favorites in Internet Explorer. How to use the Alt+C keyboard shortcut. Using Alt+C in Internet Explorer.

What is the shortcut command of Ctrl C?

Alternatively referred to as Control+C, ^c, and C-c, Ctrl+C is a keyboard shortcut used to copy highlighted text or other object to the clipboard in a graphical user environment. On Apple computers, the keyboard shortcut to copy is Command + C .


2 Answers

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();
like image 169
Xiaoy312 Avatar answered Oct 08 '22 09:10

Xiaoy312


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();

like image 25
Johan Avatar answered Oct 08 '22 08:10

Johan