m (Reverted edits by 196.46.120.125 (talk | block) to last version by JohnBot) |
No edit summary Tag: Visual edit |
||
(29 intermediate revisions by 17 users not shown) | |||
Line 11: | Line 11: | ||
|category2=Undo |
|category2=Undo |
||
}} |
}} |
||
− | To undo recent changes, use the undo command: |
+ | To undo recent changes, from normal mode use the undo command: |
*<code>u</code>: undo last change (can be repeated to undo preceding commands) |
*<code>u</code>: undo last change (can be repeated to undo preceding commands) |
||
− | *<code>Ctrl- |
+ | *<code>Ctrl-r</code>: Redo changes which were undone (undo the undos). Compare to <code>.</code> to ''repeat'' a previous change, at the current cursor position. Ctrl-r (hold down Ctrl and press <code>r</code>) will redo a previously undone change, wherever the change occurred. |
A related command is: |
A related command is: |
||
*<code>U</code>: return the last line which was modified to its original state (reverse all changes in last modified line) |
*<code>U</code>: return the last line which was modified to its original state (reverse all changes in last modified line) |
||
− | <code>U</code> is not actually a true "undo" command as it does not actually navigate undo history like <code>u</code> and <code> |
+ | <code>U</code> is not actually a true "undo" command as it does not actually navigate undo history like <code>u</code> and <code>Ctrl-r</code>. This means that (somewhat confusingly) <code>U</code> is itself undo-able with <code>u</code>; it creates a ''new'' change to reverse previous changes. |
<code>U</code> is seldom useful in practice, but is often accidentally pressed instead of <code>u</code>, so it is good to know about. |
<code>U</code> is seldom useful in practice, but is often accidentally pressed instead of <code>u</code>, so it is good to know about. |
||
− | == |
+ | ==Undo Tree== |
+ | |||
− | *[[Recover from accidental Ctrl-U]], which explains what constitutes a '''change''' which can be undone. |
||
+ | Note that unlike most programs which maintain a linear undo history, Vim maintains an undo ''tree'' containing every edit made to a buffer. To learn how to use Vim's undo tree, see the separate article on [[using undo branches]]. |
||
− | *[[Using undo branches]], which explains Vim's unique and very powerful '''undo tree'''. |
||
==References== |
==References== |
||
*{{help|undo}} |
*{{help|undo}} |
||
+ | *{{help|U}} |
||
==Comments== |
==Comments== |
||
+ | <pre> |
||
− | <code>Ctrl-R</code> means to hold down the <code>Ctrl</code> key then press the <code>R</code> key. Note that you do not press the <code>Shift</code> key. Vim documentation uses traditional computer terminology including CTRL-R. In keeping with a more modern approach, we generally use "Ctrl" rather than "CTRL" on this wiki. The tips are not entirely consistent regarding whether to write Ctrl-R or Ctrl-r, but mostly Ctrl-R is preferred. [[User:JohnBeckett|JohnBeckett]] 10:04, March 18, 2010 (UTC) |
||
+ | :nnoremap U :echo " < < ===== C H E C K C A P S L O C K ===== > > "<CR> |
||
+ | </pre> |
Latest revision as of 22:53, 28 October 2020
To undo recent changes, from normal mode use the undo command:
u
: undo last change (can be repeated to undo preceding commands)Ctrl-r
: Redo changes which were undone (undo the undos). Compare to.
to repeat a previous change, at the current cursor position. Ctrl-r (hold down Ctrl and pressr
) will redo a previously undone change, wherever the change occurred.
A related command is:
U
: return the last line which was modified to its original state (reverse all changes in last modified line)
U
is not actually a true "undo" command as it does not actually navigate undo history like u
and Ctrl-r
. This means that (somewhat confusingly) U
is itself undo-able with u
; it creates a new change to reverse previous changes.
U
is seldom useful in practice, but is often accidentally pressed instead of u
, so it is good to know about.
Undo Tree[]
Note that unlike most programs which maintain a linear undo history, Vim maintains an undo tree containing every edit made to a buffer. To learn how to use Vim's undo tree, see the separate article on using undo branches.
References[]
Comments[]
:nnoremap U :echo " < < ===== C H E C K C A P S L O C K ===== > > "<CR>