Keybindings not reliable
vvdhsb opened this issue · comments
Description of the problem or steps to reproduce
First of all love Micro, coming from Nano I find it super easy to adopt and enjoy it simplicity/plugins.
Only down side it I use MacOS with a Windows style SteelSeries keyboard and keybindings are a pita. I managed to set what I need in my bindings.json
although Micro seems to have a mind of its own and the keybindings randomly change.
This could be while using the editor or upon next use.
Looks like it could be switching between it's base default config and then my specific bindings.json config at random times, rather than just using my config. Notably, SpawnMultiCursor*
keybindings and Paragraph*
/Word*
keybindings seem to swap/unset or get messed up. Any ideas?
bindings.json
{
"\u001b[1;12A": "ParagraphPrevious",
"\u001b[1;12B": "ParagraphNext",
"\u001b[1;12C": "WordRight",
"\u001b[1;12D": "WordLeft",
"\u001b[1;2A": "SelectUp",
"\u001b[1;2B": "SelectDown",
"\u001b[1;2C": "SelectRight",
"\u001b[1;2D": "SelectLeft",
"\u001b[1;3A": "MoveLinesUp",
"\u001b[1;3B": "MoveLinesDown",
"\u001b[1;4C": "SelectWordRight",
"\u001b[1;4D": "SelectWordLeft",
"\u001b[1;5C": "EndOfLine",
"\u001b[1;5D": "StartOfLine",
"\u001b[1;6A": "SpawnMultiCursorUp",
"\u001b[1;6B": "SpawnMultiCursorDown",
"Alt-/": "lua:comment.comment",
"Ctrl-/": "lua:comment.comment",
"Ctrl-F2": "command:toggleBookmark",
"CtrlShift-F2": "command:clearBookmarks",
"CtrlUnderscore": "lua:comment.comment",
"F2": "command:nextBookmark",
"F5": "lua:wc.wordCount",
"Shift-F2": "command:prevBookmark",
"F1": "command:fzfinder"
}
Specifications
Version: 2.0.14
Commit hash: 04c57704
Compiled on August 27, 2024
OS: macos 14.6.1
Terminal: zsh```
The bindings.json file can get re-written when a new keybinding is made with bind
command, or more commonly when a plugin runs config.TryBindKey
when micro is started 1. I have used the following workarounds in the past to prevent this from happening:
- Disable plugins that use
config.TryBindKey
, or make sure all keybindings they try to set are already bound to something else 2 - Remove write permissions for your bindings.json file (
chmod -w ~/.config/micro/bindings.json
)
The re-formatting should not break any keybindings though even if the JSON looks a bit different – did some of your keybindings break? Which ones?
Footnotes
-
For example if you remove the built-in comment plugin's keybinding
"CtrlUnderscore": "lua:comment.comment"
, the plugin will "helpfully" add it back for you the next time you start micro if you didn't bind it to anything else. ↩ -
Unfortunately plugins may still opt to overwrite the keybindings (see TryBindKey documentation), but vast majority of plugins are well behaved and don't do that. ↩