Auto select first choice in spell check list

I’d love to recreate this mapping i use in vim to obsidian vim. I am new to Obsidian and type script so forgive me if this is obvious. Any advice or a nudge in the right direction would be greatly appreciated :slight_smile:

The main idea: Take the first option in the spellcheck suggestion list of the most recently misspelled word relative to the cursor

The vim mapping

function! FixLastSpellingError()
normal! mm[s1z=`m
endfunction
nnoremap sp :call FixLastSpellingError()

Explained
a normal mode function:
m mark this location. the second m is the varible name of the marking
[s go to previous misspelled word
1z= take first suggestion for the misspelled word
` go back to a marked location of m

Source Chris Toomey - Github I found it on the youtube channel thoughbot video title ’ Your First Vim Plugin’.