Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio like code snippets in Rider

Tags:

rider

Does anyone know if the JetBrains Rider IDE supports kind of "code snippets"? I usually have a snippet in Visual Studio for creating NUnit test cases, like:

[Test]
[Description("Some description")]
[MaxTime(1000)]
public void Test()
{
#region Arrange
#endregion

#region Assert
#endregion

#region Act
#endregion
}
like image 352
Moerwald Avatar asked Aug 28 '17 12:08

Moerwald


People also ask

Is JetBrains Rider better than Visual Studio?

Rider overtakes Visual Studio in terms of performance. If you're tired of slow performance, Rider is a good choice. It starts faster than Visual Studio and compiles code faster as well. I've observed that Visual Studio freezes when dealing with solutions that have many projects.

Does ReSharper work with Rider?

True to its roots, Rider supports a wide array of plugins developed for ReSharper and IntelliJ Platform. In addition to the bundled plugins (such as those for VCS, F#, and Unity support), plugins that support Markdown, . gitignore files, and Python scripts are available.

Does Rider support VB Net?

By default, JetBrains Rider automatically detects VB.NET version based on the associated compiler.


1 Answers

Yes, there is.

In Rider, it is called Live Templates.

  • Open menu File > Settings.
  • In the Settings window, expand Editor > Live Templates.
  • Click the green "+" icon to add a Template Group.
  • Click the green "+" icon to add a Template.
  • In the Abbreviation field, define the keyword you want to use to trigger it.
  • In the field Template Text, insert the code.
  • In the field Applicable in, set the context where this live template will be used.
  • In the field Expand with, select how you want to expand the code after typing your keyword.
  • Save your changes.
  • Go to the editor and type the abbreviation, and then the key you defined in the Expand with field.
  • Rider will create the code for you.

Keep in mind that Live Templates use a different syntax from Visual Studio Code Snippets, so you can check this page - Predefined Live Templates for C# - for further reference.

like image 73
Marlon Assef Avatar answered Oct 10 '22 04:10

Marlon Assef