this post was submitted on 26 Oct 2023
122 points (94.2% liked)

Linux

48364 readers
1038 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

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

Advanced Linux user: "Ctrl-Z dammit fg"

you are viewing a single comment's thread
view the rest of the comments
[–] Orbituary@lemmy.world 1 points 1 year ago (2 children)

Yeah, no.

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

,

[–] tal@lemmy.today 5 points 1 year ago* (last edited 1 year ago) (1 children)

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.

[–] Astaroth@lemm.ee 2 points 1 year ago* (last edited 1 year ago) (1 children)
[–] Orbituary@lemmy.world 2 points 1 year ago

Nope! But cool.