How to re-order content of code files?
Hi,
I used VS 19 for the last years daily and switching to Rider showed me some advantages and some disadvantages (as it's always the case when you compare two things, so no offense here). With VS 19, I was used to use "CodeMaid", an extension for formatting and cleaning code. However, I only used it for rearranging my code:
If I pressed Shift + M + Z, all the code got rearrange:
- public fields
- protected fields
- private fields
- constructor
- properties (same as fields, public, protected, private)
- methods (same as fields)
- static methods (same as fields)
Is there a feature like this already available? Using CodeMaid for a long time, it feels time intensive to manually arrange the code or just to think about "where to put new code" when there is no general rearrange thumb. It was neat: I could place a property somewhere, e.g. at the end of the file. After using the CodeMaid shortcut, it was moved to the correct position.
Please sign in to leave a comment.
You can configure this using `Preferences | Editor | Code Style | C# -> File Layout`. This can be used within a code cleanup task.
Thanks, that worked out!
I edited the template. However, I'm not sure which template is used when applying the file layout (empty, default or default with region). It would be nice to be able to add custom templates and choose the correct one in the "apply file layout" tree node within the clean up task. This is a minor luxus problem, as it won't happen too often that different templates are applied as we should follow one convention/style. However, different projects may require different conventions/styles.
You can save settings on a per project level (even commit them to VCS), so you can have different. Never done that with file layout though.