Closed kimfucious closed 1 year ago
@kimfucious https://www.npmjs.com/package/@replit/codemirror-vim
import {Vim, getCM} from "@replit/codemirror-vim"
Vim.defineEx('write', 'w', function() {
// save the file
});
Thank you very much @jaywcjlove!
I was digging around here, trying to find other commands that I could implement.
I could not find things like: :q
, :wq
, or :x
, so I used this pattern:
Vim.defineEx("x", undefined, () => {
handleExit();
});
Is that the right way to do it?
Thanks @jaywcjlove.
Yes, I got that pattern for "write," however, I was asking about commands that are other than write such as :q
, :x
, etc.
The below, all seem to work. I'm just asking if the patterns are "best practice."
Vim.defineEx("write", "w", () => {
handleQuit();
});
Vim.defineEx("q", undefined, () => {
handleExit();
});
Vim.defineEx("x", undefined, () => {
handleExit();
});
Vim.defineEx("wq", undefined, () => {
handleExit();
});
I didn't find a good solution, you can define your own package.
Thanks... I'm good with what I'm using, as mentioned prior.
First, thanks for this excellent package. It makes CodeMirror, which is kinda hard to implement, easy to use in React.
I've scoured the docs and have come up short trying to detect vim commands.
For example, if I type
:w
, that's the vim command for write.I'd like to call the
handleSave()
function in the below when:w
is executed.Any help on this would be greatly appreciated!