-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Intercept Vim-triggered newlines for the Matrix environment \\
shortcut
#352
Comments
No luck after some hacking away at this. I was hoping that this line would work: map o g$a<CR> However, it seems that Obsidian doesn't recognize as pressing Enter, which is what Matrix shortcuts expect to insert
This is where I hit a wall when it came to knowledge, and searching didn't help much. If anyone has any knowledge in either of these areas, please let me know. |
export function getVimSpecialEnterCommand(settings: LatexSuitePluginSettings): vimCommand {
return {
id: "latex-suite-vim-special-enter",
defineType: "defineAction",
type: "action",
action: (cm: CodeMirrorEditor) => {
//@ts-ignore
const vimObj: Vim | null = window?.CodeMirrorAdapter?.Vim;
if (!vimObj) return;
vimObj.handleKey(cm, "A");
const event = new KeyboardEvent("keydown", { key: "Enter" });
cm.getInputField().dispatchEvent(event);
},
key: "o",
context: "normal",
}
} something like this? it works, only it puts 2 enters instead of one. |
export function getVimSpecialEnterCommand(settings: LatexSuitePluginSettings, plugin: LatexSuitePlugin): vimCommand {
return {
id: "latex-suite-vim-special-enter",
defineType: "defineAction",
type: "action",
action: (cm: CodeMirrorEditor) => {
//@ts-ignore
const vimObj: Vim | null = window?.CodeMirrorAdapter?.Vim;
if (!vimObj) return;
vimObj.handleKey(cm, "A");
const view = EditorView.findFromDOM(cm.getWrapperElement());
const ctx = Context.fromView(view);
runMatrixShortcuts(view, ctx, "Enter", false);
},
key: "o",
context: "normal",
}
} fixed it, couldn't figure out how to get the current EditorVIew or whatever is used |
Description of the Problem
Currently, within a Matrix environment, a
\\
symbol is inserted whenever you press Enter. However, if you have have Obsidian's Vim mode enabled, and presso
to add a newline and enter Insert mode, no\\
is added.Description of the Solution
Hypothetically, the plugin would be able to detect the Vim action and add
\\
when pressingo
, just like when pressing Enter normally.I don't know if this is possible. If the newline isn't being detected by
KeyboardEvent
, I assume that Obsidian's does something like this when pressingo
:If it is possible to hook into this mechanism, it's not obvious to me how one would do it. I originally planned on making a PR to implement this, but realized I didn't know what direction to go in. I'd love some feedback on whether people think this would be possible, and if so, how it could be implemented.
The text was updated successfully, but these errors were encountered: