Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Studio, Is there a way to create code snippets as in Xcode

(Might not be the appropriate forum to ask, but..)

Is there a way to add a custom code snippet as in Xcode. In Xamarin, ToolBox section, I found the prebuilt code snippets. But if I had to add a new one, its asking for the Assembly.

In Xcode, its like we can select the code and drag onto the codesnippets pane to add it as one.

Any info regarding the same in Xamarin would be most helpful.

Thanks!

like image 820
coder284 Avatar asked Mar 06 '14 12:03

coder284


People also ask

How to make code snippet Xcode?

If you want to create a new code snippet in Xcode, you just need to select a portion of code, right-click on it and choose the option Create code snippet. Then, you can edit and delete it by pressing cmd + shift + L .


1 Answers

In Xamarin Studio open the settings menu:

  • Windows: Tools > Options
  • OS X: Xamarin Studio > Preferences

Navigate To Text Editor -> Code Templates

Here you can edit snippets that come with Xamarin studio as well as add new ones. For syntax I'd recommend just looking at one of the already present properties.

E.g. default property looks like this:

public $type$ $name$ {
    get;
    set;
}

You could change that to have a backing store:

private $type$ _$name$;
public $type$ $name$ {
    get { return _$name$; } 
    set { _$name$ = value; }
}
like image 173
Franz-Robert van Vugt Avatar answered Sep 21 '22 13:09

Franz-Robert van Vugt