How do I navigate Vim's undo tree branches to access states that u and Ctrl-R can't reach?
g- and g+
Vim's undo history is a tree, not a linear stack.
g- and g+
Vim's undo history is a tree, not a linear stack.
zO and zC
zO and zC are the recursive counterparts to zo and zc.
=ip
The =ip command combines Vim's auto-indent operator (=) with the inner paragraph text object (ip) to re-indent every line in the current paragraph in a single k
:e ++ff=unix
The ++ff modifier forces Vim to re-read the current file from disk using a specific fileformat — unix (LF), dos (CRLF), or mac (CR).
ZZ
ZZ is a normal mode shorthand that saves and quits only if the buffer has been modified.
<C-a> in insert mode
Pressing while in insert mode inserts the same text that was typed during the previous insert mode session.
:sort! n
The :sort! n command sorts the lines of a buffer (or a range) by their numeric value in descending order.
:put =strftime('%Y-%m-%d')
The :put = command inserts the result of a Vimscript expression directly into the buffer as a new line.
:undolist
Vim's undo history is a tree, not a linear stack.
:earlier {time}
Vim's :earlier and :later commands let you travel through undo history using real-world time intervals instead of individual change counts.
<C-v><Tab>
When expandtab is set, pressing the Tab key inserts spaces instead of a real tab character.
:set fileformat=unix
When you open a Windows file in Vim on a Unix system, you may see ^M at the end of every line — that's the carriage return (\r) from CRLF line endings.
:e ++enc=utf-8
When Vim opens a file with the wrong encoding — producing garbled text or incorrect characters — you can reload it with a specific encoding using :e ++enc={
:center / :left / :right
Vim has three built-in Ex commands for aligning text without any plugins: :left, :center, and :right.
zr and zm
The zr and zm commands let you incrementally adjust the global fold depth across the entire buffer — one level at a time.
:right
Vim has three built-in Ex commands for text alignment that most users never discover: :right [width] right-justifies lines, :left [width] left-justifies (strips
gw{motion}
The gw operator reformats text just like gq, but leaves the cursor exactly where it started.
<C-x><C-k>
Vim's insert-mode completion system includes dictionary lookup via .
zm
Instead of jumping between fully open (zR) and fully closed (zM), zm and zr let you step through fold levels one at a time.
<C-x><C-t>
Vim's insert-mode completion includes a thesaurus mode triggered by .