title | description | ms.date | ms.topic | author | ms.author | manager | ms.subservice | dev_langs | ||
---|---|---|---|---|---|---|---|---|---|---|
Rename a filename to match a type |
Learn how to use the Quick Actions and Refactorings menu to rename a type to match the filename, or rename a filename to match the type it contains. |
01/26/2018 |
reference |
Mikejo5000 |
mikejo |
mijacobs |
general-ide |
|
This refactoring applies to:
-
C#
-
Visual Basic
What: Lets you rename a type to match the filename, or rename a filename to match the type it contains.
When: You have renamed a file or type and haven't yet updated the corresponding file or type to match.
Why: Placing a type in a file with a different name, or vice-versa, makes it difficult to find what you're looking for. By renaming either the type or filename, code becomes more readable and easier to navigate.
Note
This refactoring is not yet available for .NET Standard and .NET Core projects.
-
Highlight or place the text cursor inside the name of the type to synchronize:
-
Next, do one of the following:
- Keyboard
- Press Ctrl+. to trigger the Quick Actions and Refactorings menu and select Rename file to TypeName.cs from the Preview window popup, where TypeName is the name of the type you have selected.
- Press Ctrl+. to trigger the Quick Actions and Refactorings menu and select Rename type to Filename from the Preview window popup, where Filename is the name of the current file.
- Mouse
- Right-click the code, select the Quick Actions and Refactorings menu, and select Rename file to TypeName.cs from the Preview window popup, where TypeName is the name of the type you have selected.
- Right-click the code, select the Quick Actions and Refactorings menu, and select Rename type to Filename from the Preview window popup, where Filename is the name of the current file.
The type or file is renamed.
- Keyboard