I previously made a post about some Mvvm Light shortcuts / code snippets in Visual Studio, but what about Visual Studio for Mac?
Code snippets in Visual Studio for Mac work a little differently, but here is how to add your own:
- Go to Visual Studio > Preferences > Text Editor > Code Snippets
- Click on the Add button
- Set the language for your snippet, the shortcut, and other optional options
- Write the template for your snippet
- Confirm and use
Here are two easy ones that have made my life easier for a Bindable Property and Relay Command:
propb:
private $type$ $fieldName$; public $type$ $name$ { get { return $fieldName$; } set { Set(() => $name$, ref $fieldName$, value); } }
rcmd:
private ICommand $fieldName$; public ICommand $name$ => $fieldName$ ?? ($fieldName$ = new RelayCommand(() => ));
It’s as easy as that. Now go out there and start writing less code!
If you like what you see, don’t forget to follow me on twitter @Suave_Pirate, check out my GitHub, and subscribe to my blog to learn more mobile developer tips and tricks!
Interested in sponsoring developer content? Message @Suave_Pirate on twitter for details.