Go to file under cursor

Is there a way to open an #include file by hovering cursor and shortcut key?

Notepad++ will do this, as will VisualStudio and VSCode.

thx

K

Hi @kmanuele. Yes, you can do that:

  1. Select the board you are using from Arduino IDE's Tools > Board menu.
  2. Select Sketch > Verify/Compile from the Arduino IDE menus.
    You can also use the button on the toolbar to trigger the sketch compilation.
  3. Wait for the compilation to finish successfully.
  4. Press and hold the Ctrl button on your keyboard.
  5. Click on the filename in an #include directive.

The file will now open in a new editor tab in Arduino IDE. This includes files from outside your sketch. In that case, Arduino IDE will not allow you to edit the contents of the file (it is only available for viewing). You can close these files by clicking the X icon on the editor tab.

Thanks, but I get no response when I do that. The #include files are those I put in the library (but did not formally create as a lib), so accessible from any sketch.

Even if it worked, unfortunate that I could not edit files I put in the library.

Which board do you have selected from Arduino IDE's Tools > Board menu?

Nano Every

without emulation

Unfortunately, the version of clangd currently in use by Arduino IDE doesn't have support for the ATmega4809 microcontroller of the Nano Every board. So it is expected that the language server-based features (which include the "Go to definition" feature that normally opens the file referenced in an #include directive on Ctrl+click) are not functional when you have the Nano Every board selected in Arduino IDE.

The Arduino IDE developers are tracking the need to update the version of clangd used by the IDE in order to add support for the Nano Every (and other boards that use microcontrollers of the "megaAVR 0-series" architecture) to the language server-based features:

If you have a GitHub account, you can subscribe to that thread to get notifications of any new developments related to this subject:


:red_exclamation_mark: Please only comment on the GitHub issue thread if you have new technical information that will assist with the resolution. General discussion and support requests are always welcome here on the Arduino Forum.


ok, and thanks, though I am surprised this particular feature would be a board-dependent issue -- since it would only need to do a local filename search.

I can live with it.

It isn't quite so simple. There may be multiple files of the given name in various places. The "Go to definition" feature must open the specific file that is used by the compiler/preprocessor, and the file that is used might differ from one board to another. If it did a naive file search and opened a different file, that would lead to a lot of confusion.