Move classes into separate files in one go
You have probably seen that ReSharper offers you the option to move a type into a corresponding file. But did you know that you can move several types into correspondingly named files in one go? For example, say you have a single file with the types Apple
, Orange
and Plum
, defined as follows:
tip
For more information, refer to the Move Types into Matching Files refactoring.
namespace MyLibrary
{
public class Apple
{
}
public class Orange
{
}
public class Plum
{
}
}
What I can do to separate these is press CtrlShift0R on the containing project in the Solution Explorer and choose Move Types Into Matching Files:
![Moving types into separate files in one go Moving types into separate files in one go](https://resources.jetbrains.com/help/img/dotnet/2024.3/cookbook_move_types.png)
ReSharper then asks which elements should be moved into separate files:
![Moving types into separate files in one go Moving types into separate files in one go](https://resources.jetbrains.com/help/img/dotnet/2024.3/cookbook_move_types1.png)
Once you press Next, the types will be separated into correspondingly named files:
![Moving types into separate files in one go Moving types into separate files in one go](https://resources.jetbrains.com/help/img/dotnet/2024.3/cookbook_move_types2.png)