reddit / emacs

help understanding how to do undo/redo.

igoryon · 2022-08-31 05:36
I cannot grasp emacs undo/redo. It's confusing and pieces me off. Can you explain, how it work, or maybe, you have a link to some simple tutorial specifically about undo/redo. I am trying to learn it from the official emacs tour page, but it's confusing.
7890yuiop · 2022-08-31 07:14
You can undo the undo in order to restore your missing pieces.
[deleted] · 2022-08-31 09:20
[removed]
arthurno1 · 2022-08-31 09:55
Press C-_ to undo. Press C-g and then C-_ to undo in other direction (redo).
artyhedgehog · 2022-08-31 10:43
First of all there is a way to make undo/redo works the more usual way. I don't remember specificly, but I believe Doom Emacs or some other prebuilt config has it by default, because I remember having to turn it off. Then, emacs undo is actually quite simple. Just think of "undo" action as something that you also can "undo" later. Of course, if that was all, you could only switch between two last states, which is pretty useless. So instead, you undo step by step into the history, with your undos stacking to the end of the history _until_ you do anything other than undo. And then your undo pointer jumps to the end of history stack, so you'll have to undo those undos first to get to the same point again.
jangid · 2022-08-31 10:54
There are quite a few options in Emacs to undo. The default one is something called undo tree. In this method, every edit action is stored on a undo tree. When you start undoing using one of the built-in keys `C-/` or `C-x u` or `C-_`, it start rolling up the tree. But remember that these undo actions are also editing actions. They are also stored in the tree. If you break the sequence of undoing by doing some other action then it breaks the sequence of undo and after that it starts undoing the undo actions also. And to reach the desired state, you will need to undo more times. More details in `(emacs) Top > Fixit > Undo`
-1Mbps · 2022-08-31 11:55
Just enable cua mode
Danrobi1 · 2022-08-31 13:08
Take a look at [vundo](https://github.com/casouri/vundo): Vundo (visual undo) displays the undo history as a tree and lets you move in the tree to go back to previous buffer states.
Illiamen · 2022-08-31 15:24
See also the new commands `undo-redo` and `undo-only`.
FitPandaFu · 2022-08-31 16:08
I find C-/ easier to press.
igoryon · 2022-09-01 01:50
Is C-/ the undo or the redo?
igoryon · 2022-09-01 01:51
I just started learning the emacs, so please explain, where do I need to look for those commands?
igoryon · 2022-09-01 02:00
>(emacs) Top > Fixit > Und 1. So, by breaking the sequence, you essentially, are creating a new branch on the undo tree? 2. (emacs) Top > Fixit > Undo . <- How do I do that?
igoryon · 2022-09-01 02:04
1) How can I do that? 2) It's good to know, how and that you can enable some mode (cua mode), that, if I understand correctly, i like a regular undo/redo?, but also, I want to understand, how the standard undo/redo system works in emacs.
7890yuiop · 2022-09-01 03:03
There is only "undo" (which is why people find it confusing at first). "Redo" is actually undoing an "undo". Which version of Emacs are you using? There are some relatively recent features designed to make the system simpler to use, but you may or may not have them. (You can insert the version string into a buffer with `C-u M-x emacs-version` and copy and paste that here.)
7890yuiop · 2022-09-01 03:05
* `C-h r` to go to the `(emacs)` manual, then `m fixit` and `m undo`, or... * `C-h i g (emacs)Undo` to jump to that node directly. Then type type `h` in the info reader and work through the info manual tutorial, which will be an invaluable investment of time.
igoryon · 2022-09-01 03:09
I installed @ work and @ home. @ home, I have the newer version of Ubuntu, so, the latest version, that has installed from the repository is, I don't remember exactly, but it's in the branch of 28 But @ home, an older version of Ubuntu, I have emax version 26.3
7890yuiop · 2022-09-01 03:16
In Emacs 28 you have the following (it was added in version 28). > ** New command 'undo-redo'. > > It undoes previous undo commands, but doesn't record itself as an > undoable command. It is bound to 'C-?' and 'C-M-_', the first binding > works well in graphical mode, and the second one is easy to hit on tty. > > For full conventional undo/redo behavior, you can also customize the > user option 'undo-no-redo' to t.
igoryon · 2022-09-01 03:57
1) So, I do Ctrl+h, and on the bottom line, it says: "C-h (Type ? for further options)-" 2) Then, I press "i" and get: "C-h (Type ? for further options) i" and some page is opened, that has the text on the bottom gray line: *info* and on top, on a dark gray line, it says: (dir)Top 3) Then, I press "g" and, on the bottom line, it says: "Go to node: " 4) I type there "(emacs)Undo" and it shortly displays on that bottom line: "Info file emacs does not exist" Do I have an incomplete "info/help" system? I've just installed emacs from the repository on Ubuntu.
igoryon · 2022-09-01 04:00
When I do "C-h r", then "m fixit", I get (at the bottom line): "Menu item: fixit [No match]"
Illiamen · 2022-09-01 04:10
They're new in Emacs 28. See here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Undo.html
igoryon · 2022-09-01 05:16
I've figured it out. There is a package on Ubuntu/Debian, called "emacs-common-non-dfsg", that I needed to install, in order for those "info" sections to appear.
-1Mbps · 2022-09-01 07:24
https://www.emacswiki.org/emacs/CuaMode
7890yuiop · 2022-09-01 07:39
That other comment is misleading -- "Undo Tree" is the name of a third-party package that provides an undo interface similar to that of Vim. The default Emacs undo system is not called "undo tree" (and AFAIK no tree is involved). The description is otherwise accurate, but very confusing on account of that mis-labelling.