Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to lower case a Visual Studio Code Snippet variable? [duplicate]

I've build some snippets to generate a fields for a setting class. I'm now using 2 variables - $setting$ and $Setting$ - to generate names for the property and the backing field. I like to use a single variable, because the only difference is that the backing field is always a lower-cased version.

Current code:

string $setting$;

/// <summary>
/// Gets the $bigComment$.
/// </summary>
/// <value>The $smallComment$.</value>
public string $Setting$
{
    get
    {
        if (String.IsNullOrEmpty($setting$))
        {
            $setting$ = CFW.Common.Configuration.GetAppSetting("$Setting$", $defaultValue$);
        }

        return $setting$;
    }
}

Is this possible?

like image 750
Kees C. Bakker Avatar asked Feb 25 '14 13:02

Kees C. Bakker


People also ask

How do you do a lower case in VS Code?

File-> Preferences -> Keyboard Shortcuts. Now CTRL+SHIFT+U will capitalise selected text, even if multi line. In the same way, CTRL+SHIFT+L will make selected text lowercase. These commands are built into VS Code, and no extensions are required to make them work.

How do I change case in VS Code?

Use Ctrl + Shift P for Windows and Linux. As shown in the image above, you can convert a string or sentence's case into: Upper case. Lower case.

How do you capitalize all letters in Visual Studio?

The two functions have default shortcut keys that make the editing process even faster. To capitalise the text press Ctrl-Shift-U. To convert to lower case, press Ctrl-U.


1 Answers

It is not possible to change literals in a Code Snippets. There are some functions available:

GenerateSwitchCases - Generates a switch statement and a set of case statements for the members of the enumeration specified by the EnumerationLiteral parameter. The EnumerationLiteral parameter must be either a reference to an enumeration literal or an enumeration type.

ClassName - Returns the name of the class that contains the inserted snippet.

SimpleTypeName - Reduces the TypeName parameter to its simplest form in the context in which the snippet was invoked.

But they cannot modify literals.

Source: http://msdn.microsoft.com/en-us/library/ms242312(v=vs.110).aspx

like image 93
Kees C. Bakker Avatar answered Sep 16 '22 12:09

Kees C. Bakker