The CircuitPython code on your board detects when the files are changed or written and will automatically
re-start your code. This makes coding very fast because you save, and it re-runs.
However, you must wait until the file is done being saved before unplugging or resetting your board! On
Windows using some editors this can sometimes take up to 90 seconds, on Linux it can take 30 seconds
to complete because the text editor does not save the file completely. Mac OS does not seem to have this
delay, which is nice!
This is really important to be aware of. If you unplug or reset the board before your computer finishes
writing the file to your board, you can corrupt the drive. If this happens, you may lose the code you've
written, so it's important to backup your code to your computer regularly.
There are a few ways to avoid this:
1. Use an editor that writes out the file completely when you save it.
Recommended editors:
mu (https://adafru.it/Be6) is an editor that safely writes all changes (it's also our recommended editor!)
emacs (https://adafru.it/xNA) is also an editor that will fulIy write files on save (https://adafru.it/Be7)
Sublime Text (https://adafru.it/xNB) safely writes all changes
Visual Studio Code (https://adafru.it/Be9) appears to safely write all changes
gedit on Linux appears to safely write all changes
IDLE (https://adafru.it/IWB), in Python 3.8.1 or later, was fixed (https://adafru.it/IWD) to write all changes
immediately
thonny (https://adafru.it/Qb6) fully writes files on save
Recommended
only
with particular settings or with add-ons:
vim (https://adafru.it/ek9) / vi safely writes all changes. But set up vim to not write
swapfiles (https://adafru.it/ELO) (.swp files: temporary records of your edits) to CIRCUITPY. Run vim
with vim -n , set the no swapfile option, or set the directory option to write swapfiles elsewhere.
Otherwise the swapfile writes trigger restarts of your program.
The PyCharm IDE (https://adafru.it/xNC) is safe if "Safe Write" is turned on in Settings->System
Settings->Synchronization (true by default).
If you are using Atom (https://adafru.it/fMG), install the fsync-on-save
package (https://adafru.it/E9m) so that it will always write out all changes to files on CIRCUITPY .
SlickEdit (https://adafru.it/DdP) works only if you add a macro to flush the disk (https://adafru.it/ven).
We
don't
recommend these editors:
notepad (the default Windows editor) and N otepad++ can be slow to write, so we recommend the
editors above! If you are using notepad, be sure to eject the drive (see below)
IDLE in Python 3.8.0 or earlier does not force out changes immediately
nano (on Linux) does not force out changes
geany (on Linux) does not force out changes
Anything else - we haven't tested other editors so please use a recommended one!
If you are dragging a file from your host computer onto the CIRCUITPY drive, you still need to do step
2. Eject or Sync (below) to make sure the file is completely written.