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

"Avoid unfolding folded sections" JS is not working

Open strangerinusall opened this issue 1 year ago • 2 comments

Hello! For some reason the Avoid unfolding folded sections does not work for me. Each time I type j or k it just starts typing :upSkipFol... and so on, instead of actually moving lines.

I have mdHelpers.js file in the root vault folder.

❯ cat mdHelpers.js
function moveUpSkipFold() {
  view.editor.exec('goUp');
}
function moveDownSkipFold() {
  view.editor.exec('goDown');
}

In my .obsidian.vimrc I have this:

" Fix for unfolding of folded lines when curor is hovered over
exmap upSkipFold jsfile mdHelpers.js {moveUpSkipFold()}
exmap downSkipFold jsfile mdHelpers.js {moveDownSkipFold()}
nmap k :upSkipFold
nmap j :downSkipFold

In Vimrc Support settings I have Support JS command optional enabled.

strangerinusall avatar Dec 22 '24 20:12 strangerinusall

Starting in Obsidian 1.7.2, ex commands (those entered with a leading : in Vim) must be followed by an explicit Enter (<CR>) to execute. Previously, Obsidian’s Vim implementation could execute some ex commands without needing <CR>, but that behavior changed with the underlying CodeMirror updates. Hence, any custom ex commands need to end with <CR>.

Below is an example of that in effect.

exmap back obcommand app:go-back
nmap <C-o> :back<CR>

adrocic avatar Feb 01 '25 03:02 adrocic

Starting in Obsidian 1.7.2, ex commands (those entered with a leading : in Vim) must be followed by an explicit Enter (<CR>) to execute. Previously, Obsidian’s Vim implementation could execute some ex commands without needing <CR>, but that behavior changed with the underlying CodeMirror updates. Hence, any custom ex commands need to end with <CR>.

Below is an example of that in effect.

exmap back obcommand app:go-back
nmap <C-o> :back<CR>

That was it, thanks!

Unfortunately this plugin this does not work for me as expected. After I do [[ or ]] it does work properly and I can use j or k to move through unfolded sections, but as soon as I use e.g. G to jump to the end of the file or O to move above current heading, it auto-expands that heading and then after manually colapsing j or k again opens the folds. Then I again need to click [[ or ]] to re-enable it.

strangerinusall avatar Feb 01 '25 11:02 strangerinusall