15

From the help zuw *zug* *zuw* zug Undo |zw| and |zg|, remove the word from the entry in 'spellfile'. Count used as with |zg|. zuW *zuG* *zuW* zuG Undo |zW| and |zG|, remove the word from the internal word list. Count used as with |zg|.


8

The change list is a different thing from the undo list. The change list is a list of locations of changes, and it can be viewed with :changes and navigated with e.g. g; and g,. The g+ and g- commands that you’re using move instead through the undo list. This is a tree of different file states: it’s what you are navigating when you undo and redo changes. The ...


4

Using :saveas keeps the undo history intact. :saveas is equivalent to the combination of :w newname followed by :e #. I usually find it more handy than the :w + :e, especially since with :saveas it's not really possible to forget about doing the second command and end up editing the first file. (Which you can guess is something I've done more than once!)


4

Original vi only supports single-level undo: the first time you press u it performs an undo, and the second time you press it it undoes the undo, going back to the state before the undo. Nvi (and possibly other implementations of vi) allow you to perform more undoes first by pressing u, and then by pressing . to repeat the undo operation. Vim augments undo ...


3

Doing :let &ul=&ul breaks the undo sequence. This is documented under :h :undojoin: Setting the value of 'undolevels' also breaks undo. Even when the new value is equal to the old value. Using the described method, you can do the following: nnoremap <leader>d dd:let &ul=&ul<CR>dd


3

Typically, Vim considers a mapping or a recorded macro as a single change, so if you press u to undo it, it will undo all of it. There exists the possibility to break an undo-sequence into smaller parts, so that you can undo each part of it independently. For that, the generic way is to enter CTRLGu in Insert mode. (See :h i_CTRL-G_u). So simply add CTRLGu ...


2

I've used undotree for a while without any real issues.


2

I use argdo in this answer, same rule applies to bufdo, windo , ... . Don't use argdo undo argdo undo failes in these conditions: Some buffers remain unchanged after last argdo, might caused by 0 pattern match, execute undo on them is a mistake, it will undo changes made by older argdo. An error occurs during your last argdo, when an error occurs, argdo ...


1

Tim Pope created eunuch plugin with such feature. It has :Move and :Rename commands. Do not know if it works under Windows since description is about UNIX shell commands, can't test it right now. Also as filbranden said you can copy with :saveas.


1

I think building on your logic @dedowsdi one could then do argdo if &modified | earlier | endif I can see how one could have several wrapper functions written around this, that's great!


Only top voted, non community-wiki answers of a minimum length are eligible