Whenever I program an Arduino based project I would always use Sublime Text as my editor then compile and upload using the Arduino IDE. I prefer using Sublime Text as my Arduino Sketch editor as it gives more flexibility on color highlighting.
This post is a tutorial on how to use Sublime Text as an External Editor. It also answers the why, advantages and disadvantages of using External Editor.
In case you prefer to use Atom Text Editor than Sublime Text then you may still do so by opening your code on Atom Text Editor.
- Using an External Editor without setting the Arduino IDE properly
- How to use an External Editor in Arduino IDE
Before I show you on how to properly set the Arduino IDE to use an External Editor, let me show you first on what happens when you use an External Editor without doing the proper setup.
I opened the same .ino file on the Arduino IDE and on Sublime Text. Then I edited the one on Sublime Text.
Note: The code is a stripped down version of the Blink Code.
Then I edited the code on Sublime Text and saved it.
Then without editing or saving the code on the Arduino IDE I compiled the code.
The normal Blink code sketch would only use 928 bytes (2%) of program storage space. Therefore, the one compiled on the above experiment was the modified Blink code with 4 lines of additional code.
That is cool and all since you can modify your code on an External Editor and compile it on the Arduino IDE. But what if you forgot that you were using an External Editor and edited the code on the Arduino IDE instead? This actually happened to me and with a snap of a finger I said goodbye to 3 days worth of coding.
To avoid this we must set properly the Arduino IDE to use an External Editor. See the steps below.
On your Arduino IDE go to File >> Preferences.
Inside the Preferences window find and check the Use external editor check box. Then press OK.
Once you have done the above instructions the Arduino IDE editor would then be colored grey. You can try editing the code on your Arduino IDE but the program would not allow you to do any changes.
I did the same experiment as the above.
I edited the code on Sublime Text and saved it.
When I clicked on anywhere in the Arduino IDE the code was updated to the new saved version.
With that I can make sure that what I compile on my Arduino IDE is the latest version of my Project Code without worrying that I would overwrite it whenever I forget that I am using a different editor.
Do you use an External Editor for your Arduino projects? What editor do you usually use? Tell me your answers on the comments below.