10

(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!

1 Answer 1

25

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; }
}
Sign up to request clarification or add additional context in comments.

6 Comments

How do you do this in Xamarin Studio 5.5?
Alright, so the Text Editor menu is in Preferences.
Where can I change the default values of $type$ and $name$ ?
@zil , you can change it in the dialog. E.g. if you click on _$name$ you see a menu popup on the right where you can change these sort of settings. Screenshot of dialog
Oh wow thanks. My brain completely ignored this whole part of the screen.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.