I’m an Emacs newbie (using Doom Emacs with GNU Emacs 29.1). I came from vim, and battling with undo there was crazy enough, but I won using this:

inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap , ,u
inoremap . .u
inoremap ( (u
inoremap [ [u
inoremap = =u
inoremap \" \"u
inoremap  u
inoremap  u

Also, I had autogroup that breaks undo every 4 seconds.

Basically, this configuration breaks undo on almost every possible type command, every Spacebar, Enter, comma, bracket, moving up, down, everything. This is because I hate when undo deletes the whole screen of text.

How do I replicate this in Emacs? I read this, but it doesn’t say what is considered a “recent change”.

  • 7890yuiop@fediverser.communick.devB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    What does “break undo” mean? Do you mean that if you type “x” and then you type “y” and then you use undo, the first undo should remove only the “y” and the second would remove the “x”?

      • juboba@fediverser.communick.devB
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 months ago

        I think you are not used to ‘modal’ editing in Vi. How does the world use it? With atomic edits, which means living in NORMAL mode and only entering INSERT mode when you need it. Your undo history works like a commit history and you can undo by action: inserted text, changed text inside brackets, deleted 6 lines, etc. If you get used to this, you’ll never go back (even in Emacs, Evil user here hehe).

        • chesheersmile@fediverser.communick.devOPB
          link
          fedilink
          English
          arrow-up
          1
          ·
          11 months ago

          This way of modal editing is fine when you write source code.

          I write texts, articles. Most of the time I spend in Insert mode. And when I press u I see a wall of text disappeared.

          • thetemp_@fediverser.communick.devB
            link
            fedilink
            English
            arrow-up
            1
            ·
            11 months ago

            And when I press u I see a wall of text disappeared.

            Maybe Vim let’s things go too far between undos.

            I write a lot of text too, but I’ve never seen Emacs’s undo remove a whole wall of text that was typed by hand. If it was inserted from the kill-ring, sure.

            Occasionally, it’ll undo a few more keystrokes than I’d prefer, but that’s rare. In that case, you can just undo the undo by pressing “C-g C-/”. And then remove only the text you wanted to get rid of.

            • oantolin@fediverser.communick.devB
              link
              fedilink
              English
              arrow-up
              1
              ·
              11 months ago

              Maybe Vim let’s things go too far between undos?

              By default Vim makes each foray into insert mode undo in a single step. So you have total control over how much gets undone each time: just exit and renter insert mode if you want more granular undo.

      • 7890yuiop@fediverser.communick.devB
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 months ago

        I think /u/bravosierrasierra has your solution with amalgamating-undo-limit then. Except the docstring may have an off-by-one error: experimentally it seems as if you need (setq amalgamating-undo-limit 0) rather than the indicated value of 1.