Hello,
So I am loving IDE 2.0.3, the dark theme is easy on my eyes and coding etc is a pleasure ![]()
My question is, is there a way to remove a file name from the horizontal list of file names in a project. I don't want to delete it from the project folder or being built as part of the project, just remove its name from the list. I use VS2023 and the file names at the top have a little (x) on the tab to close any file you are not currently working on and I would like to do same in Arduino IDE 2 please.
Many thanks in advance imk
Hi @imk123. Arduino IDE is intentionally designed to not allow the closure of sketch code file tabs.
Since many of the common sketches consist of only a single file, Arduino users are often under the impression that the .ino file is unit of a sketch project. But this is not true. It is the folder that is the sketch project. The folder may contain multiple sketch code files. All the source files present in that folder are compiled to a single program. In addition, all the .ino files of a sketch are concatenated into a single C++ source file before compiling. This concatenation can be confusing even for users who are advanced in C++ programming but fairly new to Arduino.
This is all documented, but Arduino is intended to make the creation of embedded systems accessible even to the type of person who won't read the documentation before jumping in to a project. The Arduino way is to make these complex endeavors as intuitive as possible. Arduino IDE communicates the sketch project file system intuitively by using a separate window for each sketch project and opening all the primary source files as editor tabs, with the tabs are in the order of .ino file concatenation.
You will notice I said "primary sketch code files". Additional code files can be added to the src subfolder of the sketch. This folder is intended to contain files which are not intended to be visible to the user by default. A prominent example of the use of this feature is the Marlin 3D printer firmware. That firmware is a very complex Arduino sketch consisting of hundreds of files. But the average user of the firmware doesn't need to access all the source files. They only need the files that contain the configuration. So the sketch files that contain the configuration are in the root of the Marlin sketch, and everything else is in the src subfolder.
Even though they are not opened in the editor by default, Arduino IDE 2.x does allow the user to open the files from the src subfolder. The tabs of these files are closable. So if there are files you want to be closable, you can put them in the src subfolder of your sketch. Something important to note is that .ino files are not supported in the src subfolder, so you can only put .h, .cpp, .c, .S files there.
I'll provide instructions you can follow to open these files on demand:
- Select File > Preferences... from the Arduino IDE menus.
- Check the box next to "☐ Show files inside Sketches.
- Click the OK button.
- Click the folder icon on the "activity bar" on the left side of the window to open the "Sketchbook" view.
- Use the ❯ control to expand the folder of the sketch and its
srcsubfolder, if not already. - Click the file you want to open.
You will notice the opened tab has an X icon you can click to close it.
ptillisch many thanks for the info,
However in step 5. no files are shown after project being restarted
Think it maybe due to Sketchlocation being at c:\Users\Me\Documents\Arduino
and my sketch being at D:\NewDev\Robots\ERIN-Production\ERIN_ProdMotorSensor_V1-4
I always keep my development stuff/work on a different disk from the OS (Windows 10)
As gives me a layer of protection from OS imploding/virus etc
Many thanks Ian
Ah, yes, I should have mentioned that requirement. As the name implies, the "Sketchbook" view only shows the contents of your sketchbook folder.
This is no problem because you can configure the sketchbook folder location:
- Select File > Preferences... from the Arduino IDE menus.
- Set the "Sketchbook location" preference to the location you would like to use as your sketchbook (e.g.,
D:\NewDev). - Click the OK button.
hello ptillisch many thanks for the info,
Changed Sketchbook location from c:\Users\Me\Documents\Arduino
to my project at D:\NewDev\Robots\ERIN-Production\ERIN_ProdMotorSensor_V1-4
and now I get compiler errors Compilation error: VL53L0X.h: No such file or directory
Plus i have several projects on the go so changing Sketchbook location all the time will be a pain.
Hence I think i'll have to live with status quo, mank thanks for you help Ian
In addition to being a convenient place to store your sketches, the sketchbook is also the place where Arduino IDE Library Manager installs libraries. They are installed in the libraries subfolder of the sketchbook folder. So when you change the "Sketchbook location" preference, your previously installed libraries are no longer accessible to Arduino IDE. You can move the contents of the previous sketchbook location to the new one after changing the preference.
You can set the "Sketchbook location" preference to a parent folder under which multiple sketches are stored. If you like, you can even organize your sketches into subfolders under that sketchbook container folder.
But of course if you prefer to store your sketches in some other location outside the sketchbook folder, that is OK also. The sketchbook is a convenient place to store sketches, and the IDE has some features that enhance the user experience when sketches are stored in that location (the File > Sketchbook menu, the "SKETCHBOOK" view), but those features are completely optional and the essential functionality is the same regardless of where the sketch is located.
hello ptillisch many thanks for the info
Sorry what i meant to say was I keep all personal data, projects, software I am developing etc on my D: and all operating system, IDE's, etc etc on C: . So unfortunately Arduino IDE2 SketchBook
is currently implementation is incompatible with how i like work, shame as looks really nice feature. Maybe sometime the development team would like to consider adding another chkbox to preferences to include SketchBook feature to local .ino/project fold. I still think IDE2 is truly magical and the ready written libraries is rapidly setting Arduino as the standard for MicroController development. Thanks again Ian
Can you please expand on that ?
For instance, why do you need to keep changing the Sketchbook location ?
You nee to read my posts in this thread
I have and still don't see why you have to keep changing the location of your Sketchbook folder. Set it to a location on your preferred drive, install or copy the libraries to the libraries folder in the Sketchbook folder then use a different folder in your Sketchbook folder for each of your projects
The installed libraries and any that you install subsequently will be available to to your projects
My apologies if I have misunderstood the problem
Arduino IDE has a feature called the "Explorer View" that does what you hope for.
The "Explorer View" is only accessible via the the advanced secondary user interface and Arduino does not provide any support for this feature, so it is to be used on an "as is" basis.
I'll provide instructions you can follow to enable the "Explorer View":
- Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
- Select the "Toggle Explorer View" command from the menu.
You will now see the "Explorer View" has opened in the left side panel of the Arduino IDE window. The view shows the contents of the folder of the sketch that is open in the IDE. You can select files from the src subfolder of the sketch to open them in the Arduino IDE editor in closable tabs.
A new icon is added to the "Activity Bar" on the left side of the window. Click that icon when you want to toggle the visibility of the "Explorer View".
Hello UKHeliBob and many thanks for your post.
It comes down to Church and State. I have my OS and ALL tools IDE's, libraries etc etc on the OS drive and a second drive D: with all my project data, personal files on. I have four PC's that ALL have the SAME OS build, my main office PC, my HTPC PC, my workshop PC and a spare PC. All the same build, motherboard, PSU , ssd OS drive and case etc. plus I backup regularly my D: development, personal files disk. Hence if I have a system failure (like the NEW Samsung SSD that failed after a week last month) I can simply unplug my active D: disk and put it in one of the other PC's and I am back in business. If the D: disk was damaged I use one of the TWO D: disk backups I keep. I have been in IT for 50 plus years now and have simply learnt to keep valuable data away from operating systems. A knowledge that should have been known to the so called professional IT directors of companies that are hit by ransomwear. It quit the industry at 55 as I was fed up with arguing with them as, oh Ian it will never happen! They ignored one time and nearly killed 600 people, but that's a story for another day.
imk
hello ptillisch and many thanks for the almost perfect solution.
So i opened Explorer View and added it to the Activity Bar (Easy, many thanks)
I had a look around and could see the files in my project etc and was able to select whichever I wished, very nice
I then opened the .theia folder and launch.json, which was added to the file name view at top of the IDE which had a little (x) that I clicked launch.json (x) and it was closed.
Hence, if I was asked what enhancements to add to IDE2 I would say:
- Add the option to make icon's like "Explorer View" added to the Activity Bar permanent so when the IDE is closed and reopened I don't have to follow the Command Palette process every time.
- In the Explorer View add the (x) tab to all the file names in the list of files in the project/sketch.
Many thanks again for the help imk
The configuration of the Arduino IDE UI (AKA "workbench") is stored on a per-sketch basis. So you should find that if you run the "Toggle Explorer View " command on a given sketch, the Explorer icon will still be in the Activity Bar, and even the visibility of the Explorer view remembered every time you open that sketch again. So you will only need to do this the first time you open a sketch.
Some very old beta versions of Arduino IDE 2.x did not remember this configuration, but the modern versions do just fine. I just tested it out to be sure.
I am not suggesting that you put your data anywhere near the OS. Unless I have misunderstood your requirements or how the IDE finds libraries, the OS can be on drive C: and the Sketchbook and libraries can be on drive D: if that is what you want
If I am mistaken, then please accept my apologies in advance
I just tested it with same project on 2.0.3 and it works, most wonderful!
Many thanks again ptillisch
IDE2 just keeps getting better and better ![]()
You're welcome ![]()