Closed digitalmaster closed 4 months ago
I'm not sure if I understand the scenario correctly, but are you trying to reference another key definition in the keymap? If so, you can simply do it using JavaScript in the config file with two stages:
// define direct keys
let keymap = {
normal: {
h: "cursorLeft",
j: "cursorDown",
k: "cursorUp",
l: "cursorRight",
w: [
"cancelSelection",
"cursorWordStartRightSelect",
]
}
};
// define recursive keys
keymap.normal.Z = [ keymap.normal.h, keymap.normal.w ];
module.exports = keymap;
Or even with getter functions (note: this can only access keybindings at the same level):
let keymap = {
normal: {
h: "cursorLeft",
j: "cursorDown",
k: "cursorUp",
l: "cursorRight",
w: [
"cancelSelection",
"cursorWordStartRightSelect",
],
get Z() { return [ this.h, this.w ]; }
}
};
module.exports = keymap;
Oh wow! Of course 🙈😅.. it's just JS. So used to doing this in json that I forgot. Thanks will give it a shot. Thank you 😊
Side note: Are there any advanced or fully fleshed out examples of bindings I could reference?
I think presets/helix.js
is an example you could look at. Not sure if it's advanced enough for you.
Gotcha.. I guess i'm just trying to get a sense for how to do basic movements like da(
(which deletes everything around the current parens) or si'
(which selects text inside single quotes).
For example, these two references for ModalEdit really helped me figure things out:
Here is my current mappings: https://gist.github.com/anthonyjclark/1de4882c13ffd3c61863bc657557253e
You might be able to grab some things from there.
Thank you kind sir. 🙌
Hi 👋 - I'm testing out this plugin (currently migrating from ModalEdit). Is there a way to reuse existing bindings in other ones? ModalEdit does this with the
modalEdit.typeNormalKeys
command which simulates typing an exiting binding.For example, how would you implement something like "delete inside [char]"? In ModelEdit we define select command that selects the range, then just call typeNormalKeys with
vi[char]
thendeleteRight
, then insertMode.How do we achieve something similar here?
Thanks for the help 🙏