How to edit library source in IDE, on Mac

I've extracted some common code from one Sketch into a set of .h and .cpp files that I use as a library. I wanted to update an old project to also use these libraries, which might need some (hopefully) small adjustments to be compatible with both sketches.

So I wanted to have both sketches and the library open in the 2.3.6 IDE and be able to view and edit all three.

I've found lots of discussion about this over the years and the best summary seems to be this one from the prolific and always very helpful @ptillisch

I've set up my library as described but still can't get the IDE to automatically open my library files, and in the Open command they're still dimmed. I'm on MacOS which may have differing file types and permissions.

However one good workaround I've found is to use the View: Toggle Explorer keyboard option to create the Explorer button in the left pane. And using the explorer I can open and edit any of my library files. And the net result is that I can now have both sketches and my library open simultaneously.

So for other Mac uses wanting to do the same thing I wanted to share the tip of using View: Toggle Explorer. (Default shortcut is Command-Shift-E, or use the Command-Shift-P shortcut to see the keyboard shortcut dialog and then search for explorer to find its current mapping) Also useful to know is the Command-Shift-Period shortcut to enable visibility of filenames starting with a Period like the .development file needed in this procedure.

1 Like

Good tip, I didn't know about Explorer. I have been using BBEDIT for library C++ and H files, now I have an additional option.
Some viewers may not know they need to use Shift-Command-P (Mac) to bring up the extra commands window.

Yes, I've sometimes been using BBEdit for .h and .cpp files too. And that works great on a big monitor when I can see both sets of windows. Currently I need to do everything on the MacBook screen so I wanted to keep everything in the IDE windows, and flit between them with Command-`

I hadn't heard of the Explorer window either, but it was another gem I discovered in a @ptillisch post.

1 Like

Nothing happens when I use Command`

I am not a Mac user but

is not the same as

Could that be the problem ?

I am not sure what you think the difference is. Command- shrinks the window so I left the - out.
Maybe I need to examine the additional commands palette.

The difference is that you are not using the same keystrokes. Whether that matters I do not know

I keep the IDE for sketches and use an alternate editor for library files. I find it easier that way to just switch app when I want to see one part of the code or the other part rather than having to deal with an endless list of tabs in the IDE.

I think the - is just to seperate the Command and but I tried both Command- and Command`. both do nothing.

macOS's Command+` keyboard shortcut switches between the windows of the application:

https://support.apple.com/en-us/102650#:~:text=your%20open%20apps.-,Command–Grave%20accent,-(`)%3A%20Switch%20between

Command–Grave accent (`): Switch between the windows of the app you're using. (The character on the second key varies by keyboard. It's generally the key above the Tab key and to the left of the number 1.)

If you only have one window of the application open, then it won't have any effect.

Try this:

  1. Start Arduino IDE.
  2. Select File > New Sketch from the Arduino IDE menus.
    You will now have at least two windows of the Arduino IDE application open: the window(s) that opened when you started Arduino IDE, and the new sketch window opened by File > New Sketch.
  3. Press the Command+` keyboard shortcut.

One of the other Arduino IDE windows should now take focus. You can press the keyboard repeatedly to efficiently switch between the windows.

1 Like

Perfect, I had multiple tabs, which is what happened when I used the explorer option. Now I can use both tricks together!
This is a game changer!

Yeah, I use this keyboard shortcut a lot; probably second only to the copy and paste keyboard shortcuts. It can dramatically increase the efficiency of some tasks compared to using the mouse to switch windows.

Except in cases where I truly do need to see the contents of multiple windows at the same time, I find that I generally prefer to work with a single window maximized on my screen, rapidly switching between each of the windows or applications that I am working with simultaneously by using keyboard shortcuts. On macOS, it is useful to also know the Command+Tab shortcut, which switches between applications. On Linux and Windows, Ctrl+Tab switches between all the windows of all applications, so you only need one keyboard shortcut when using those operating systems.

1 Like

Yes I agree. There is some really good secret sauce hiding in the IDE!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.