Skip to content

Instantly share code, notes, and snippets.

@citizenmatt
Last active December 18, 2015 22:49
Show Gist options
  • Save citizenmatt/5857410 to your computer and use it in GitHub Desktop.
Save citizenmatt/5857410 to your computer and use it in GitHub Desktop.
ReSharper Live Template to create class with underscores in name

Edit the "Class" File Template (ReSharper -> Templates Explorer -> File Template -> C# -> Class) to be this:

$HEADER$namespace $NAMESPACE$
{
  $SELSTART$// File: $FILENAME$.cs$SELEND$
  public class $CLASS$ {}
}
  • On the right of the window, click the "Change macro" link for FILENAME, select "Current file name without extension".
  • Click the "Change macro" link for CLASS and select "Value of another variable, where spaces are replaced with '_'"
  • Click the "another variable" highlighted in red, select FILENAME from the drop down.
  • Save and close the Class template. Make sure "Class" is in the quicklist section in the Templates Explorer (it sometimes moves it out of there)
  • When you Alt+Insert, you can now create a file with spaces, and the class name has underscores. Annoyingly, you need to have the filename comment so that the macro knows what to convert. The template ends with that highlighted, so you can simply delete it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment