How to edit the File, New Sketch "sketch" not Examples/01.Basics/BareMinium

i have found this, https://forum.arduino.cc/t/how-to-modify-default-arduino-sketch/324425 which shows how to edit the examples/01.Basics/BareMinium which i have done.

HOWEVER,

I want to edit the file "New Sketch" so every time it is opened, it is how I edited it like with BareMinium.

Tips, pointers?

EDIT: I am using the nightly build incase that is of signifigance and using the linux version.

This is how I edited my custom newsketch.ino:

#define DEBUG 0
#if DEBUG == 1
#define debug(x) Serial.print(x)
#define debugln(x) Serial.println(x)
#else
#define debug(x)
#define debugln(x)
#endif

void setup() {
	Serial.begin(9600);

}

void loop() {

}

I'm sure i'll edit it as time passes!! :dog2: :dash:

Welcome to the forum

Allow customization of default sketch

arduino/arduino-ide#1559, arduino/arduino-ide#

When a new sketch is created, Arduino IDE populates it with the bare minimum empty setup and loop functions.

Some users may wish to adjust this code. That is now possible by specifying the path to a file containing the custom content in the advanced settings:

  1. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
  2. Select the "Preferences: Open Settings (UI)" command from the menu.
  3. A "Preferences" tab will now open in the IDE. In the "Search Settings" field, type arduino.sketch.inoBlueprint
  4. Add the path to the file containing your custom new sketch content in the field under the "Sketch: Ino Blueprint" setting.
  5. Click the X icon on the "Preferences" tab.
  6. Select File > Quit from the Arduino IDE menus.
  7. Start the Arduino IDE.
2 Likes

Read this discussion:

1 Like

Note that the system of modifying it via the BarMinimum sketch is specific to Arduino IDE 1.x. Arduino IDE 2.x uses a dedicated sketch separate from the examples for this purpose, as explained by UKHeliBob.

Maybe worth an update to that tutorial @LarryD ?

1 Like

We’ll see if the link can be unlocked for editing.

1 Like

THANK YOU UKHeliBob!!!
I did not even know this preference menu existed!!

Worked like a champ!

I got to thinking...

That works like a champ what you recommended UKHeliBob!! :+1:

however that still begs the question, WHERE is it getting the default new sketch file from in the first place? Its not BareMinimum so where is it getting the information to put into the sketch when you call up a new sketch?? :thinking:

Curiosity kills me... :cat2:

Would be nice to know!! :nerd_face:

That is fine, however if you dont save as... before you begin, it will start autosaving to your BareMinimum file, at least it does for me.
I know you can turn autosave off BUT, power outages, Cat walking on keyboard etc etc ... you get the idea!

It is here:

1 Like

So you can edit that OR go the Preferences way. Neat thanks for that!
That more completely answers my question!!!

You are welcome.

If you are interested in playing around with the Arduino IDE 2.x source code, this could definitely be a good starting point and I definitely encourage you to give it a try. You can learn about running the IDE from source here:

https://github.com/arduino/arduino-ide/blob/main/docs/development.md#development-guide

However, I would not consider this an effective approach for a user who only wants to customize the File > New Sketch sketch because you will need to redo the customization each time you update to a new version of Arduino IDE. The old "BareMinimum" system of Arduino IDE 1.x had the same problem, except that modifying that sketch file generally took less effort. I think it would only make sense to do if you were maintaining a fork of the Arduino IDE 2.x codebase with other modifications in addition to the custom File > New Sketch sketch.

1 Like

Definately going to dig into the source code to at least get a better understanding of IDE, i see where your coming from with customization with new releases, better to do it the way the solution is.

To me, it should be in the File>Preferences section, not buried in a pile of other options that are hidden from newer users.

Should be in a easier to find area. More user friendly and would be a QOL upgrade.

The reason it was put in the advanced settings instead of the Preferences dialog is because this is something only a tiny fraction of advanced IDE users will have any interest in doing.

The Preferences dialog is intended to only contain the settings the average user needs access to. If we are to add this setting, where does it end? For you, this is a significant setting, but for someone else one of the other settings (e.g., "Editor › Hover: Delay") is more significant. Before long the Preferences dialog becomes massive and makes the IDE less approachable to beginners.

1 Like

How about a link from the IDE menu or the Preferences dialogue to the Command Palette for those that want to get to it ?

2 Likes

I think it is a good idea. Arduino IDE 1.x's Preferences dialog had the equivalent by providing the link to the preferences.txt file where that application's advanced settings could be adjusted.

1 Like

I have a copy of each skeleton file in the folder just for that kind of thing :woozy_face:

1 Like

Works a treat, thanks @UKHeliBob.

One further question please... is there a way to automatically insert the file creation date (and perhaps other useful meta data) in a '//' comment line in the default sketch so that it auto populates with the date/time when the file was created?

Thanks.

I am glad that it works

As to inserting the file creation date there is no way to do that as far as I know

The nearest thing that I can think of is that you can print __DATE__ and/or __TIME__ from a sketch to print the compilation date and/or time if that helps

1 Like

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