anyone know if there is a way to save the write in vim while you add some text, like the undo/redo but that ones can play that afterwards like codility editor. Thanks
-
1You mean like persistent undo? This is already in Vim. See [`:help 'undofile'`](http://vimhelp.appspot.com/options.txt.html#%27undofile%27) and [How can I use the undofile?](https://vi.stackexchange.com/q/6/51). – Martin Tournoij Jun 25 '17 at 01:45
-
hemmm.. it's more than nothing, but now, I should undo all the file until it get empty and then do :redo until it get filled up again, but that way I guess I'll missing some undo in between..for example if I write: 123\n 456\n :wg then I'll roll back and the redo will works fine, but if I write 123\n 678\n :u 456\n :wq the redo method will miss the 678\n. I wanna these to see how my owm writing evolved in time. – pslavkin Jun 26 '17 at 02:08
-
The undofile only saves the undo steps from the past, not any previous steps you've undone. – Martin Tournoij Jun 26 '17 at 04:31
1 Answers
First, Vim's undo is not just a simple linear sequence as in most other applications, it actually stores a full tree that includes edits that were later undone. This tree can be navigated with built-in commands like g-
and :earlier
; more comfortably with plugins like Gundo or undotree.vim. That's a good approach to recall a previously discarded alternative solution. (Using version control and frequent, atomic commits would be even better.)
If you want to record your entire editing session, this built-in command-line option is for you:
-w {scriptout} All the characters that you type are recorded in the file
"scriptout", until you exit Vim. This is useful if you want
to create a script file to be used with "vim -s" or
":source!". When the "scriptout" file already exists, new
characters are appended.
I'm not sure how well this works in practice (you'd have to save and restore the original file contents somewhere, too). There's definitely no "speed control" or stepping through.
If you want to replay your whole editing process itself, I would recommend some screen recording software (dependent on your operating system, and whether you use GVIM or the terminal). Those typically generate some video (e.g. MP4) from it, which is convenient to view in any movie player (including skipping and fast-forward). But it's a bit large as a long-term storage format.

- 167,457
- 16
- 250
- 324
-
Thanks Ingo, I'll take it a shot and I'll let you know. Screen recording is not an option, 'cose you answer from yourself, I'll examine the -w option.. maybe a combination of these solution plus some scripting achive my goal. Tks! – pslavkin Jun 27 '17 at 05:14