How is it possible to skip a command wile using redo (ctrl-R) ? I made a mistake and put my file in lowercase, I can go back and undo the command, how can I redo all the other commands done after?
How to skip a command in redo
115 views Asked by Penbeuz At
2
There are 2 answers
0
On
Vim's undo-redo is very powerful, supporting not just one linear sequence but a full tree (cp. :help undo-branches
). Unfortunately, what you ask for still isn't possible, as Vim stores each command (and its effects) relative to the others; skipping any would wreak havoc on the entire undo history.
To achieve something like this, you need to pre-record the steps in a macro (as suggested by @mMontu); the macro commands inside the register can then be undone, edited, and re-executed.
I think there is no easy way to do that. I assume the changes were quite complex and that you may have spent some time reviewing them, otherwise you could just type them again. You could try the following options:
:help q
), type the changes, stop recording, then change the whole text to lowercase (gggUG
). Then you can diff it against your previous version (windo difft
) -- it will remind you of any change missing, and you save the time of checking every detail of the changes:DiffOrig
, which is defined on the default vimrc ($VIMRUNTIME/vimrc_example.vim
) and explained on the help files, to compare your final text against the version before changing to lowercase, them you can understanding whether it is easier to repeat the changes or to fix the case of the text.Edit:
The
:DiffOrig
would help you to do what you explained in the comments.Also notice that it is probably possible to edit and them apply the undo history, but it may be more complicated to achieve than to redo your changes manually. If this is something common on your workflow it may be worth -- on that case you could base and include it on some existing plugin on the subject, such as undotree.