obsidian-vimrc-support
obsidian-vimrc-support copied to clipboard
Command + sleep 0.5s + <down> key?
exmap linkloadtitle obcommand obsidian-auto-link-title:enhance-url-with-title
I want to map :linkloadtitle command + sleep 0.5s + T key.
Some inspiration (didn't work):
Tried a macro:
nmap t :linkloadtitle
qatjq, then @a, but :linkloadtitle command messes with text on the next line somehow so additional delay before consequent run is required
tried to do this with the following snippet
const vimObj = window.CodeMirrorAdapter.Vim
vimObj.defineEx("abc", "", async (cm, params) => {
this.app.commands.executeCommandById("obsidian-auto-link-title:enhance-url-with-title")
await new Promise((resolve) => setTimeout(resolve, 1000))
})
and with command
:nmap t :abc
and tried qatj
but codemirror-vim/codemirror doesn't wait on async code and there is no way to sleep synchronously in javascript.
So this is not really possible.
You can do while(new Date() < ...) {/* do nothing */} but thats not sleeping and I don't know how well that works.