All commands
Everything in micropython.nvim is one command, :MP, followed by a subcommand: :MP run,
:MP upload, :MP repl and so on.
- Type
:MP <Tab>to complete a subcommand.:MP mipand:MP flashalso complete their first argument. - Run
:MPon its own to pick a subcommand from a list. Commands picked this way run without arguments. - Only
:MP sendtakes a line range, as in:'<,'>MP send.
At a glance
Section titled “At a glance”| Command | What it does |
|---|---|
| Running code | |
:MP run |
Run the current file on the device without uploading it |
:MP run_main |
Run the project’s main.py from any buffer |
:MP upload |
Upload the current file, keeping its project path |
:MP upload_all |
Upload the whole project, skipping unchanged files |
:MP mount |
Mount the project on the device without copying anything |
| REPL | |
:MP repl |
Open or focus the REPL split |
:MP send |
Send the current line, or a range of lines, to the REPL |
:MP send_buffer |
Send the whole buffer to the REPL |
:MP interrupt |
Interrupt code running in the REPL (Ctrl-C) |
| Files on the device | |
:MP files |
Browse, open, edit, download and delete device files |
:MP list_files |
Print the device’s files as a tree |
:MP erase |
Erase one file or folder at the top of the device |
:MP erase_all |
Erase every file on the device |
| Device and firmware | |
:MP info |
Show the firmware, board, storage and clock, and set the clock |
:MP reset |
Soft reset the device |
:MP hard_reset |
Hard reset the device |
:MP mip |
Install a package on the device with mip |
:MP flash |
Install or update MicroPython firmware with mpflash |
| Project and stubs | |
:MP init |
Create a new project with stubs for the connected device |
:MP install |
Install the project’s Python dependencies and stubs |
:MP set_stubs |
Switch the project to different stubs |
:MP health |
Check your setup with :checkhealth |
| Ports | |
:MP set_port |
Choose the port the device is on |
:MP list_devices |
List the serial devices that are connected |
How commands run
Section titled “How commands run”Commands run in one of three ways:
- In the background. Uploads, resets,
mipand similar commands show a notification when they start and another when they finish. If one fails, the notification includes mpremote’s error. - In a terminal.
run,mount,list_files,erase_allandflashopen a terminal so you can watch the output and type into it. Most wait for Enter before closing, so you can read the result. - In a window or picker.
files,info,eraseandset_portopen a window or a list to choose from.
Terminals and pickers use snacks.nvim when it’s
installed. Otherwise terminals open in a floating window, and pickers use vim.ui.select. In
the floating terminal, <Esc><Esc> leaves terminal mode and q closes it.
The REPL holds the port
Section titled “The REPL holds the port”Only one program can use a device’s serial port at a time. While the REPL is open, it holds the port:
:MP runand:MP run_mainrun your code in the open REPL instead of starting mpremote.:MP flashcloses the REPL before it starts.- Every other command that talks to the device needs the port for itself. Quit the REPL with
Ctrl-]before using them.