micro-editor/micro · error
Invalid event %s
Error message
Invalid event %s
What it means
Thrown by findEvents() in internal/action/bindings.go while parsing a key *sequence* like "<Ctrl-x>k". The regex `<(.+?)>` splits the string into <token> groups and each token must resolve via findSingleEvent (a known key name in keyEvents/mouseEvents, modifiers + single rune, or an escape sequence). If any single token inside the angle brackets is unrecognized, parsing aborts with 'Invalid event <token>'. This surfaces through findEvent, i.e. every TryBindKey/UnbindKey/BindKey call including InitBindings at startup and the interactive >bind command.
Source
Thrown at internal/action/bindings.go:128
// InfoMapKey(e, v)
// }
}
var r = regexp.MustCompile("<(.+?)>")
func findEvents(k string) (b KeySequenceEvent, ok bool, err error) {
var events []Event = nil
for len(k) > 0 {
groups := r.FindStringSubmatchIndex(k)
if len(groups) > 3 {
if events == nil {
events = make([]Event, 0, 3)
}
e, ok := findSingleEvent(k[groups[2]:groups[3]])
if !ok {
return KeySequenceEvent{}, false, errors.New("Invalid event " + k[groups[2]:groups[3]])
}
events = append(events, e)
k = k[groups[3]+1:]
} else {
return KeySequenceEvent{}, false, nil
}
}
return KeySequenceEvent{events}, true, nil
}
// findSingleEvent will find binding Key 'b' using string 'k'
func findSingleEvent(k string) (b Event, ok bool) {
modifiers := tcell.ModNone
// First, we'll strip off all the modifiers in the name and add them to theView on GitHub (pinned to 1c8b82b32e)
Solutions
- Fix the token inside <...> to a name micro knows: Ctrl<Letter>, Alt<Rune|Name>, Shift<Name>, F1-F12, PageUp/Down, Home, End, ArrowUp/Down/Left/Right, Delete, Insert, MouseLeft/Middle/Right (optionally with Drag/Release suffix)
- Open > help keybindings and copy the exact event-name grammar from the shipped documentation
- For single characters use the bare rune ('x') and for raw escapes use "\u001b..." RawEvent form instead of inventing names
- Re-run micro and watch the infobar; the message names exactly which token failed
Example fix
// before: ~/.config/micro/bindings.json "<Cntrl-s>": "Save", "<Ctrl-x>quux": "Quit" // after "CtrlS": "Save", "<Ctrl-x>k": "Quit"
Defensive patterns
Strategy: validation
Validate before calling
// Validate a binding string before TryBindKey/BindKey
tokenRe := regexp.MustCompile(`<(.+?)>`)
func validBinding(k string) bool {
for _, m := range tokenRe.FindAllStringSubmatch(k, -1) {
if !validSingleEvent(m[1]) {
return false // each <token> must itself be a valid event name
}
}
return true
}
// validSingleEvent mirrors findSingleEvent: optional Ctrl/Alt/Shift prefixes +
// known key name (F1..F12, PageUp, Enter, ArrowLeft...), known mouse name
// (optionally +Drag/+Release), or exactly one rune. Try / catch
if _, err := action.TryBindKey(seq, act, true, true); err != nil {
if strings.HasPrefix(err.Error(), "Invalid event ") {
// extract the token, suggest closest known event name, keep going
log.Printf("skipping bad binding %q: %v", seq, err)
continue
}
return err
} Prevention
- Source event names only from > help keybindings, never from other editors' docs
- Lint bindings.json in CI with a regex pass over <...> tokens
- Prefer simple single-key names (CtrlS, AltLeft) over exotic sequences when scripting binds
When it happens
Trigger: bindings.json (or a >bind argument) contains a sequence with a bad inner token, e.g. "<Ctrl-q><quux>": 'Ctrl-q' parses but 'quux' is not in keyEvents/mouseEvents and is longer than one character, so findSingleEvent returns !ok and findEvents errors. Also triggered by typos like "<Cntrl-s>" or "<Page Down>" inside brackets.
Common situations: Hand-editing bindings.json using Vim/Emacs-style notation that micro does not support; copying snippets from outdated blog posts or other editors' configs; renaming a binding in a Lua plugin that calls bindings.TryBindKeyplug.
Related errors
- Error reading bindings.json: %s
- %s is not a bindable event
- Error reading bindings.json file: %s
- Color-link statement is not valid: %s
- Error reading settings.json: %s
AI-assisted analysis of micro-editor/micro@1c8b82b32e (2026-08-15).
Data as JSON: /api/errors/b64442c4b18778ec.
Report an issue: GitHub.