Renaming Source Files and Projects

There are several methods of renaming files and projects, depending what the result shall be.

In any case, you will have to open the Solution Explorer window. If it is not open, press [Ctrl+Alt+L].

Solution Explorer Rename Files/Projects

Warning 16 Note:

The main .ino file, the containing folder on your hard disk and the project must always have matching names.

Do not rename the project (Red 'x' above), Rename the main .ino file instead, as shown below. This will rename the project and the disk folder as well.

 

If you want to rename the project and the containing folder...
Click on the main source file (blink.ino in our example), it is the one containing the setup() and loop() functions, this file has the same name as the project. Press [F2] and give the source file a new name. This will also rename the project and the containing folder on your hard disk, so that all fit together.
If you want to rename a single source file...
Click on the source file, press [F2] and give the source file a new name. If this was the "main" file containing the setup() and loop() functions, the project will be renamed as well, see above.
If it was any other file, only the file will be renamed.

If the source file has a matching header file (like "somefile.cpp" and "somefile.h"), then it is recommended to also rename the header file and the #include statements that reference it, so that you will have a pair of files with matching file names again.
If you want to rename a single header (.h) file...
Open the "Header Files" node in Solution Explorer and rename the file in the same way as for source files.
Do not forget to change all #include references to your header file in all source files where it is used.

 

If you have a situation where the containing folder, the main .ino file and the project have mismatched names, here is how you put everything in order:

  • Rename the project by clicking on the project name, pressing [F2] and renaming the project
  • In Solution Explorer, select the main .ino file, press F2 and rename it to match the name of the project
  • Close the solution with File > Close Solution
  • Open Windows Explorer, rename the disk folder
  • Reopen the Solution with File > Recent Projects and Solutions