Renaming all variables of a model from camelCase to snake_case


For some strange reason (something to do with postgres) I was tasked with renaming all our model properties from camel case to snake case. I found the String Manipulation Rider plugin that does that but unfortunately it only renames the property, it does not refactor the rest of the code accordingly.

My question is: is there a way to automate or semi-automate this process? Ideally I would select one property and it would be renamed from camel case to snake case throughout the entire solution like the standard Rename feature does.


Comment actions Permalink

Hello Jose Simas,


There is a way to semi-automate this process. You can record a macro of this process and apply it to the properties you need. Macro will include renaming with String Manipulation combined with Rider's refactoring to achieve your goal.


I've recorded a sample macro that should help you with the renaming. The only input required from your side is to hit paste when prompted to rename the property and confirm the refactoring. Note that the caret should be placed right after the property name for this to work.


The macro looks like this:

<macro name="StringManipulationRefactor">
      <action id="EditorPreviousWordWithSelection" />
      <action id="StringManipulation.ToSnakeCaseOrCamelCase" />
      <action id="EditorCopy" />
      <action id="$Undo" />
      <action id="RenameElement" />
You can place it as a new "macro" item in your macros.xml file in your options folder (located under C:\Users\{your_user}\JetBrains\Rider{version}\options on Windows). Rider should be restarted when you add a new macros manually to the .xml file. You should see a new macro after restart in the Edit->Macros menu
If you do not have any macros yet, you will not see macros.xml in the options folder. You can generate this file by recording and saving any macro.
Let me know if this helps.
Comment actions Permalink

Hi Kirill,

Many thanks! I did not know about macros and this is exactly what I need.


Comment actions Permalink

Hi Jose,


Glad it works for you, have a nice day!


Please sign in to leave a comment.