1

I noticed that when I fold some text with zf and then press u for undo it does not undo the fold but undoes the last text editing action. Is there a general-purpose undo command which also would undo the action of having created some fold? It should be as if the command did not happen, so I can imagine the cursor returning to the end of the highlighted range where it was, for example.

1
  • I really wish there was a solution for folding to be part of history too.
    – cassepipe
    Mar 22 at 14:06

1 Answer 1

3

You don't undo a fold, you open it with zo or delete it with zd (this doesn't delete content, only suppresses the notion that there's a fold there, closable with zc).

In general, try :help followed by the keystroke you've tried to find out more. :help zf leads you to the topic of folds, and these other commands are documented there.

2
  • 1
    Thanks. I did know that I can undo a fold. I meant that the standard undo command, "u", appears not to apply to the act of folding. Maybe it applies only to editing commands. If folding counts as a motion, maybe there's an "undo last motion" command instead. If there was, you could call it from anywhere rather than having the cursor on the specific fold to undo it; and you could keep calling it to undo various consecutive previous actions, of which a fold was just one.
    – hmltn
    Oct 6, 2021 at 13:32
  • 1
    Indeed, undo is reverting a change. Folding, saving, pasting,... are not changes and are not in the undo tree - of which you can think of as a git tree of commits, see :help 32.1 and following. A jump motion can be reverted by using the jump history (<kbd>CTRL</kbd>-<kbd>O</kbd>). Oct 6, 2021 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.