Beginning Linux user: “Ctrl-Z is undo, right?”

Advanced Linux user: “Ctrl-Z dammit fg”

  • Orbituary
    link
    21 year ago

    Yeah, no.

    If ‘esc-u’ doesn’t work, I :q!

    ,

    • @[email protected]
      link
      fedilink
      5
      edit-2
      1 year ago

      I will bet that vim has some form of non-destructive undo as well. Might take an add-on package, but generally-speaking, useful behavior in emacs and vim tend to get ported to each other.

      googles

      Yup.

      https://learnvim.irian.to/basics/undo

      In Vim, every time you press u and then make a different change, Vim stores the previous state’s text by creating an “undo branch”. In this example, after you typed “two”, then pressed u, then typed “three”, you created an leaf branch that stores the state containing the text “two”. At that moment, the undo tree contained at least two leaf nodes: the main node containing the text “three” (most recent) and the undo branch node containing the text “two”. If you had done another undo and typed the text “four”, you would have at three nodes: a main node containing the text “four” and two nodes containing the texts “three” and “two”.

      To traverse each undo tree nodes, you can use g+ to go to a newer state and g- to go to an older state. The difference between u, Ctrl-R, g+, and g- is that both u and Ctrl-R traverse only the main nodes in undo tree while g+ and g- traverse all nodes in the undo tree.

      Undo tree is not easy to visualize. I find vim-mundo plugin to be very useful to help visualize Vim’s undo tree. Give it some time to play around with it.

      It sounds like vim+vim-mundo and emacs+undo-tree operate kind of similarly, actually.

      EDIT: In fact, this is definitely the case. According to emacswiki, emacs’ undo-tree is based on vim’s model.