Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Vim's modal editing results in the user explicitly defining undo/redo points.

? How? Does switching to normal mode create an undo/redo point? Someone asked me if the granularity of Vim's undo/redo could be increased (i.e., more frequent undo/redo points). In what they demonstrated, Vim's granularity seemed less than other applications (i.e., undo/redo acted on relatively large chunks of input); in some brief research, I didn't find a solution.



Well, in Vim, "switching to normal mode" can be thought of as "ending an insert command" instead of "switching modes", which makes sense as soon as you realize that normal mode is, well, normal.

So when you press "o", I don't think "switch to insert mode". I think "insert a line with the following text:", which can then be undone with u, repeated with ., or whatever else you want.

At least that's my mental model of Vim, I don't know which is closer to reality.


The "solution" is to simply leave insert mode more often. That works great if you are using Vim for editing. If you are using Vim for writing... well, not so much.

Then again, if I am writing in Vim, I generally prefer the flow of actively editing what I wrote rather than undoing it.

This really applies to Vim as a whole: if you enjoy its UX, it's damn near perfection. If you hate it, you can leave. If you love it, but want it to behave just a little differently...then you can probably accomplish that with a plugin/configuration.

...but if you want to change Vim's UX more than a little, you're fucked. It feels totally possible until you realize it just isn't.


There’s a trick to remap space to automatically insert an undo point in vim: https://stackoverflow.com/a/4360415/13099

But, after getting used to vim’s commands, I find I go back to normal mode relatively quickly and so my undo steps are generally logical.


Simply stated, 'u' in vim undoes every change since the last insert.

I suppose for some, "more granular" undo points could be useful, but I'm in such a habit of doing something discrete and then escaping insert mode, that I've never felt pinched by the potential for vim's large undos.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: