Vim syntax highlighting and filetype plugin for MMBasic (PicoMite).
✨ Complete Syntax Highlighting
- All MMBasic keywords, functions, and commands
- Control structures (IF, FOR, WHILE, SELECT CASE, etc.)
- Hardware commands (SETPIN, PWM, I2C, SPI, etc.)
- Graphics commands (PIXEL, LINE, CIRCLE, TEXT, etc.)
- WiFi/Network commands for WebMite
- Comments, strings, numbers (decimal, hex, binary, octal)
- Pin names (GP0-GP47)
🎨 Smart Editing Features
- Automatic indentation
- Code folding for SUB/FUNCTION blocks
- Matchit support for block structures
- Useful abbreviations (pr→PRINT, inp→INPUT, etc.)
- Case-insensitive keyword matching
📚 Based on Official Documentation
- Synchronized with PicoMite User Manual V6.02.00
- Supports all Raspberry Pi Pico variants (RP2040, RP2350, RP2350B)
- Includes WebMite WiFi commands
Copy the files to your Vim directory:
Unix/Linux/Mac:
mkdir -p ~/.vim/{syntax,ftdetect,ftplugin,doc}
cp syntax/mmbasic.vim ~/.vim/syntax/
cp ftdetect/mmbasic.vim ~/.vim/ftdetect/
cp ftplugin/mmbasic.vim ~/.vim/ftplugin/
cp doc/mmbasic.txt ~/.vim/doc/
# Generate help tags
vim -c 'helptags ~/.vim/doc' -c quitWindows:
mkdir %USERPROFILE%\vimfiles\syntax
mkdir %USERPROFILE%\vimfiles\ftdetect
mkdir %USERPROFILE%\vimfiles\ftplugin
mkdir %USERPROFILE%\vimfiles\doc
copy syntax\mmbasic.vim %USERPROFILE%\vimfiles\syntax\
copy ftdetect\mmbasic.vim %USERPROFILE%\vimfiles\ftdetect\
copy ftplugin\mmbasic.vim %USERPROFILE%\vimfiles\ftplugin\
copy doc\mmbasic.txt %USERPROFILE%\vimfiles\doc\
vim -c "helptags ~\vimfiles\doc" -c quitVim-Plug:
Plug 'path/to/mmbasic-vim'Vundle:
Plugin 'path/to/mmbasic-vim'Pathogen:
cd ~/.vim/bundle
git clone path/to/mmbasic-vimThe plugin automatically activates for files with .bas or .mmb extensions.
Open any MMBasic file:
vim myprogram.basKeywords will be highlighted automatically!
Fold SUB and FUNCTION blocks:
:set foldmethod=syntax
zc " Close fold
zo " Open fold
za " Toggle foldJump between matching keywords:
% " Jump between IF/ENDIF, FOR/NEXT, etc.In insert mode:
pr<space> → PRINT
inp<space> → INPUT
fn<space> → FUNCTION
sb<space> → SUB
The plugin sets these defaults:
tabstop=2- Tab widthshiftwidth=2- Indent widthexpandtab- Use spaces instead of tabsautoindent- Auto-indent new linessmartindent- Smart indentation
To override in your .vimrc:
autocmd FileType mmbasic setlocal tabstop=4 shiftwidth=4' MMBasic Example - LED Blink
OPTION EXPLICIT
CONST LED_PIN = GP21
CONST DELAY = 500
SUB Blink(times AS INTEGER)
LOCAL i AS INTEGER
FOR i = 1 TO times
PIN(LED_PIN) = 1
PAUSE DELAY
PIN(LED_PIN) = 0
PAUSE DELAY
NEXT i
END SUB
' Main program
SETPIN LED_PIN, DOUT
Blink(10)
PRINT "Done!"IF condition THEN
' statements
ELSEIF condition THEN
' statements
ELSE
' statements
END IF
FOR i = 1 TO 10 STEP 2
' statements
NEXT i
DO WHILE condition
' statements
LOOP
SELECT CASE variable
CASE 1
' statements
CASE 2 TO 5
' statements
CASE ELSE
' statements
END SELECT' Pin configuration
SETPIN GP21, DOUT
SETPIN GP26, AIN
SETPIN GP0, I2C SDA
SETPIN GP1, I2C SCL
' Digital I/O
PIN(GP21) = 1 ' Set high
x = PIN(GP2) ' Read pin
' Analog input
voltage = PIN(GP26) * 3.3 / 4095
' PWM output
PWM GP5, 1000, 50 ' 1kHz, 50% duty
' I2C communication
I2C OPEN 100, 1000
I2C WRITE &H48, 0, 1, &H01
I2C CLOSECLS ' Clear screen
COLOUR 255, 0, 0 ' Red
BOX 10, 10, 100, 100 ' Draw box
CIRCLE 160, 120, 50 ' Draw circle
TEXT 10, 200, "Hello!", "LT", 2 ' Display textView the full documentation in Vim:
:help mmbasicThe syntax file uses standard Vim highlight groups:
Statement- Keywords (IF, FOR, PRINT, etc.)Function- Built-in functions (SIN, COS, LEN, etc.)Type- Data types (INTEGER, FLOAT, STRING)Operator- Operators (AND, OR, NOT, MOD, etc.)Comment- Comments (' and REM)String- String literalsNumber- Numeric constantsConstant- Pin names (GP0-GP47)
These work with any Vim color scheme!
Supports:
- Vim 7.0 and later
- Neovim
- All PicoMite firmware versions
- WebMite (WiFi versions)
File Extensions:
.bas- BASIC files.mmb- MMBasic files
For complete MMBasic reference:
- PicoMite Manual: http://geoffg.net/Downloads/picomite/PicoMite_User_Manual.pdf
- Official Site: http://geoffg.net/picomite.html
- Community: http://mmbasic.com
- Forum: http://www.thebackshed.com/forum/Microcontrollers
Same as Vim itself. See :help license in Vim.
- MMBasic: Geoff Graham & Peter Mather
- PicoMite: Peter Mather (matherp)
- Manual: Geoff Graham with community input
- Vim Plugin: Based on PicoMite User Manual V6.02.00
Issues, suggestions, and improvements welcome!
Based on the official PicoMite User Manual V6.02.00 (February 11, 2026).
Happy MMBasic coding in Vim! 🚀