I’d like to propose an alternate way of handling the
keyMap inside of Obsidian. Currently, there are two ways of modifying the
keyMap value of CodeMirror:
The second option only exists on Mac OS, which makes handling
keyMap logic ‘simple’ on non-Mac platforms (
app.vault.config.vimMode), but since Obsidian is cross platform, any plugin developer needs to account for Mac OS, so the complexity is still there no matter what.
keyMap option was presented as a dropdown, instead of two booleans, there would be some immediate wins from this:
- Any plugins that have to set up their own CodeMirror instance, or run something like a
SwapDoccommand, could easily set the
keyMapoption to match whatever the user intends it to be by reading from
- It would eliminate the impossible to fulfill state of having both ‘Legacy Emacs-style’ and ‘Vim’ bindings enabled. The current result of having both these enabled is that ‘Vim’ mode is preferred. But that is not obvious to the end user, and only happens because of the way the logic handles the different boolean flags.
One dropdown would solve this, and give one less option to the user. This would also simplify the internal Obsidian logic, since you would just be setting a direct value. Here are some plugins that could benefit from this change:
There may be others as well.