Recommended Editors
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. On macOS, saves get slower for every swap or backup file an editor writes to CIRCUITPY. See below to move them off the drive.
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.
To avoid the likelihood of filesystem corruption, use an editor that writes out the file completely when you save it. Check out the list of recommended editors below.
Recommended editors
- mu is an editor that safely writes all changes (it's also our recommended editor!)
- emacs is also an editor that will fully write files on save. Set it up to keep backup and lock files off CIRCUITPY, as shown below.
- Sublime Text safely writes all changes
- Visual Studio Code appears to safely write all changes
- gedit on Linux appears to safely write all changes
- IDLE, in Python 3.8.1 or later, was fixed to write all changes immediately
- Thonny fully writes files on save
- Notepad++ flushes files after writes, as of several years ago. In addition, you can change the path used for "Enable session snapshot and periodic backup" to write somewhere else than the CIRCUITPY drive. This will save space on CIRCUITPY and reduce writes to the drive.
Recommended only with particular settings or add-ons
- vim / vi safely writes all changes. But set up vim to not write swapfiles (.swp files: temporary records of your edits) to CIRCUITPY. Otherwise the swapfile writes trigger restarts of your program and make every save slower. Use the
.vimrcsettings below. - The PyCharm IDE is safe if "Safe Write" is turned on in Settings->System Settings->Synchronization (true by default).
- If you are using Atom, install the fsync-on-save package or the language-circuitpython package so that it will always write out all changes to files on CIRCUITPY.
- SlickEdit works only if you add a macro to flush the disk.
Editors that are NOT recommended
- notepad (the default Windows editor) can be slow to write, so the editors above are recommended! If you are using notepad, be sure to eject the drive.
- IDLE in Python 3.8.0 or earlier does not force out changes immediately. Later versions do force out changes.
- nano (on Linux) does not force out changes.
- geany (on Linux) does not force out changes.
- Anything else - Other editors have not been tested so please use a recommended one!
Moving editor swap files off CIRCUITPY
On macOS, every swap, backup or lock file an editor writes to CIRCUITPY adds time to each save. Keep them on your computer instead.
vim
Make a swap folder in your home directory, then add these lines to ~/.vimrc. Saving code.py went from 4.5 seconds to 1.1 seconds.
mkdir -p ~/.vim/swap
" keep swap files on the local disk, not next to the file (slow on CIRCUITPY) set directory^=~/.vim/swap// " CIRCUITPY: skip the temporary backup copy on save autocmd BufReadPre,BufNewFile /Volumes/CIRCUITPY*/* setlocal nowritebackup
emacs
Make backup and auto-save folders in your home directory, then add these lines to ~/.emacs.d/init.el. Saving went from 1.5 seconds to 1.1 seconds, with nothing extra written to CIRCUITPY.
mkdir -p ~/.emacs.d/backups ~/.emacs.d/auto-save
;; keep backup, auto-save and lock files off CIRCUITPY
(setq backup-directory-alist '(("." . "~/.emacs.d/backups/")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save/" t)))
(setq backup-by-copying t)
(setq create-lockfiles nil)
Page last edited
Text editor powered by tinymce.