How do I do redo (i.e. “undo undo”) in Vim?

谁说胖子不能爱 提交于 2019-12-04 07:17:54

问题


In Vim, I did too much undo. How do I undo this (that is, redo)?


回答1:


Ctrl+r




回答2:


Also check out :undolist, which offers multiple paths through the undo history. This is useful if you accidentally type something after undoing too much.




回答3:


Strange nobody mentioned :earlier/:later. To redo everything you just need to do

later 9999999d

(assuming that you first edited the file at most 9999999 days ago), or, if you remember the difference between current undo state and needed one, use Nh, Nm or Ns for hours, minutes and seconds respectively. + :later N<CR> <=> Ng+ and :later Nf for file writes.




回答4:


Vim documentation

<Undo>      or                  *undo* *<Undo>* *u*
u           Undo [count] changes.  {Vi: only one level}

                            *:u* *:un* *:undo*
:u[ndo]         Undo one change.  {Vi: only one level}

                            *CTRL-R*
CTRL-R          Redo [count] changes which were undone.  {Vi: redraw screen}

                            *:red* *:redo* *redo*
:red[o]         Redo one change which was undone.  {Vi: no redo}

                            *U*
U           Undo all latest changes on one line.  {Vi: while not
            moved off of it}



回答5:


In command mode, use the U key to undo and Ctrl + r to redo. Have a look at http://www.vim.org/htmldoc/undo.html.




回答6:


First Press ESC key to exit from edit mode.

Then,

For Undo use u key as many times you want to undo.

For Redo use CTRL +r key




回答7:


Refer to the "undo" and "redo" part of vim document.

:red[o] (Redo one change which was undone) and {count} Ctrl+r (Redo {count} changes which were undone) are both ok.

Also the :earlier {count} (Go to older text state {count} times.) could always be a substitute for undo and redo.




回答8:


CTRL+r

The "r" is lower-case.




回答9:


Using VsVim for Visual Studio?

I came across this when experimenting with VsVim, which provides bindings for vim-commands in Visual Studio.

I know about ctrlr in vim itself, but this particular binding does not work in VsVim (at least not in my setup?).

What does work however, is the command :red. This is a little bit more of a hassle than the above, but still fine when you really need it.




回答10:


Practically speaking, the :undolist is hard to use and vim’s :earlier and :later time tracking of changes is only useable for course-grain fixes. Given that, I resort to a plug-in that combines these features to provide a visual tree of browsable undos, called “gundo.” Obviously this is something to use only when you need a fine grain fix, or you are uncertain of the exact state of the document you wish to return to. See: https://sjl.bitbucket.io/gundo.vim/



来源:https://stackoverflow.com/questions/1555779/how-do-i-do-redo-i-e-undo-undo-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!