codemirror-vim icon indicating copy to clipboard operation
codemirror-vim copied to clipboard

Allow CM6 keymaps before vim extension

Open liamhess opened this issue 5 months ago • 0 comments

Hey, In our setup we want to capture the escape key before and after the vim extension receives it and decide with the returned boolean whether the next handler should get the event or not. However if I understand correctly, this behavior is currently not supported? Because if you have a look at my setup here, the issue is that as soon as you add a second keymap, the vim extension doesn't get any Escape key events anymore and you basically can't exit insert mode once you enter it. Now I've seen that there were attempts to do this before, that were dismissed https://github.com/replit/codemirror-vim/pull/93. So is it possible to pick up the PR for this again or do you guys know any alternative for me to achieve a similar behavior?

To reproduce:

import { EditorView, keymap } from "@codemirror/view";
import { vim } from "@replit/codemirror-vim";

new EditorView({
	extensions: [
		keymap.of([{ key: "Escape", run: () => false }]),
		vim(),
		keymap.of([{ key: "Escape", run: () => true }]),
	],
	parent: document.body,
});

liamhess avatar Sep 08 '25 16:09 liamhess