Join next change with previous undo block
Example
Normal 0 / 4Command-line 1 / 4Normal 2 / 4Normal 3 / 4Normal 4 / 4e twoCursor on line 1, column 1e twoCursor on line 1, column 1e twoCursor on line 1, column 1 twoCursor on line 1, column 1e twoCursor on line 1, column 1Join next change with previous undo block.
Vim registers
"Unnamed register- Characterwise · Uses Small delete register
n -Small delete register- Characterwise
n
Undo history
- seq_cur
3- seq_last
3- save_cur
0- save_last
0- synced
1
Command entered · ready to apply
Vim registers
"Unnamed register- Characterwise · Uses Small delete register
n -Small delete register- Characterwise
n
Undo history
- seq_cur
3- seq_last
3- save_cur
0- save_last
0- synced
1
Submitted standalone :undojoin · the next keypress starts a new undo block
Vim registers
"Unnamed register- Characterwise · Uses Small delete register
n -Small delete register- Characterwise
n
Undo history
- seq_cur
3- seq_last
3- save_cur
0- save_last
0- synced
1
Separate x created undo block 4
Vim registers
"Unnamed register Changed- Characterwise · Uses Small delete register
e -Small delete register Changed- Characterwise
e
Undo history
- seq_cur
4- seq_last
4- save_cur
0- save_last
0- synced
1
Undid only x · earlier changes kept
Vim registers
"Unnamed register- Characterwise · Uses Small delete register
e -Small delete register- Characterwise
e
Undo history
- seq_cur
3- seq_last
4- save_cur
0- save_last
0- synced
1
Before & after
e twoCursor on line 1, column 1Vim registers
"Unnamed register- Characterwise · Uses Small delete register
n -Small delete register- Characterwise
n
Undo history
- seq_cur
3- seq_last
3- save_cur
0- save_last
0- synced
1
e twoCursor on line 1, column 1Vim registers
"Unnamed register Changed- Characterwise · Uses Small delete register
e -Small delete register Changed- Characterwise
e
Undo history
- seq_cur
3- seq_last
4- save_cur
0- save_last
0- synced
1
Start in Normal mode. Separate real changes prepare undo history. For undojoin, the next x and u expose whether the changes form one undo block.
Details & Vim help
Example replayed in Vim
Join next change with previous undo block. This Ex reference uses the full command name; the alphabetical index omits arguments. Supply the ranges, arguments, flags and prerequisite state documented in the linked help. Press Enter to submit a complete command. The index spelling :undoj[oin] puts the optional abbreviation suffix in square brackets; those brackets are not typed. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative. Submitting :undojoin alone does not join a change entered with the next keypress; that keypress starts a new undo block. Use it with a related following change in the same command or script, for example :undojoin | delete. Do not use it after undo or redo. The displayed separate x and u demonstrate this limitation: u restores only the x deletion.