obsidian-vimrc-support icon indicating copy to clipboard operation
obsidian-vimrc-support copied to clipboard

Command + sleep 0.5s + <down> key?

Open d9k opened this issue 1 year ago • 1 comments

exmap linkloadtitle obcommand obsidian-auto-link-title:enhance-url-with-title

I want to map :linkloadtitle command + sleep 0.5s + key to 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

d9k avatar Jun 13 '24 11:06 d9k

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.

superle3 avatar Sep 09 '25 23:09 superle3