In Vim, I frequently find myself wanting to do a quick zk or zj to jump to the previous or next fold in a file. The problem is, I frequently want to skip all the open folds, and just jump to the nearest closed fold.
Is there a way to do this? I see no built-in keymap in the manual.
No, there isn't (as far as I know) a build in method to do that. Interesting idea, though.
If I had some time at the moment, I might try to figure out a way to do it - unfortunatelly, being busy nowadays all I can suggest you is to look at the Detecting a folded line or an incremental search question (particularly the
foldclosed
function) and try to make a function yourself. Checking every line, if fold is open, skip ... something along those lines.Let me propose the following mappings implementing described behavior.