I've made a small code snippet to create a property for WPF data bingings:
private string property;
public string Property
{
get { return this.property; }
set
{
this.property = value;
this.OnPropertyChanged(() => Property);
}
}
It is pretty cumbersome to create the field name in Camel Case and rewrite the property in Pascal Case. Is there a way to only write the field and let the snippet writes the property using the name of the field with the first character in upper case?
To create or edit your own snippets, select User Snippets under File > Preferences (Code > Preferences on macOS), and then select the language (by language identifier) for which the snippets should appear, or the New Global Snippets file option if they should appear for all languages.
Code snippets can be accessed in the following general ways: On the menu bar, choose Edit > IntelliSense > Insert Snippet. From the right-click or context menu in the code editor, choose Snippet > Insert Snippet.
In VSCode, open a folder that will contain your new project. Use the Command Palette to execute the command "Project: Create Project From Template". A list of available templates should appear. Select the desired template.
There are two ways to add a snippet: Type the # symbol into the text editor. Start typing the snippet shortcut, then select the snippet from the dropdown menu. The snippet will automatically populate in the text editor.
Unfortunately this type of logic is not available in the Visual Studio snippets functionality. Having to type out both names is the best you can do.
Here are the only "functions" available to you when creating a code snippet. MSDN Code Snippet Functions
Products like Resharper provide excellent code snippet (called Templates in Resharper) functionality, with the ability to change the casing of other replacements within the snippet, among many other useful functions. Resharper Template Info
For example, you would be interested in this macro:
"Value of another variable with the first character in lower case"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With