Is there a way to get the IDE to open .cpp files?

Is there a way to get the Arduino IDE to open .h or .cpp files from a library for editing? I know I can use an external editor, and I usually use Eclipse. But I wanted to take advantage of code completion for some names that weren't set up in my Eclipse environment for a quick piece of code. But I couldn't figure out how to make it open.

Hi @Delta_G. You can create a .ino file with name matching the folder name in the folder that contains the library code files. You can then open the .ino file in Arduino IDE like any other sketch and edit the library code files in the IDE.

@ptillisch is the expert, but I would look at making an INO file with your .h and .cpp files as included. Even if there is no other code the .h and .cpp files will be brought up as tabs, and I believe you can edit them as well.

So I need a dummy .ino file with the right name. I'll try that

That sounds like a nice trick...

But wondering about how to open library files and/or core files in the IDE to use in the debugger.

Sometimes I can get the files, by setting a breakpoint somewhere in my sketch and walk into or back out into the library, which opens the file. But sometimes there are no direct ways for this.

Like trying to debug USB Hub code, where you never call the hub, but instead maybe call into devices that are plugged into the hub...

I think this will work:

  1. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
    A menu will appear on the editor toolbar:
    image
  2. Select the "Toggle Explorer View" command from the menu.
    You can scroll down through the list of commands to find it or type the name in the field.
    The "EXPLORER" view will open in the Arduino IDE left side panel.
  3. Click the ●●● icon in the toolbar for the sketch's section of the "EXPLORER" view.
    A menu will open.
  4. Select "Add Folder to Workspace..." from the menu.
    The "Add Folder to Workspace..." dialog will open.
  5. Select the folder that contains the files in which you want to set breakpoints from the "Add Folder to Workspace..." dialog.
  6. Click the "Select Folder" button.
    The folder will be added in the "EXPLORER" view.
  7. Click on a file in which you want to set a breakpoint.
    The file will open in a tab in the editor view.
2 Likes

Thanks, that appears to work

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