How do I restore a file to its state at a specific time?
:earlier 10m
The :earlier command restores the buffer to its state at a specific time in the past.
233 results for "10@a"
:earlier 10m
The :earlier command restores the buffer to its state at a specific time in the past.
<C-w>| and <C-w>_ / <C-w>=
Vim lets you temporarily maximize a split window to full width or full height, and then restore all windows to equal sizes with =.
buffers-windows #windows #splits #navigation #productivity #layout
:g/pattern/normal @a
The :g (global) command combined with :normal @a lets you execute a recorded macro only on lines matching a pattern.
macros #macros #ex-commands #global-command #editing #automation
:%s/\d\+/\=submatch(0)+1/g
Vim's expression replacement (\=) in substitutions lets you perform arithmetic on matched text.
:lvimgrep /pattern/ %
While :vimgrep populates the global quickfix list, :lvimgrep uses the window-local location list instead.
{count}{motion}
Almost every Vim motion and operator accepts a numeric count prefix that repeats or amplifies the action.
:call setreg('a', @a, 'l')
Registers in Vim have a type — characterwise, linewise, or blockwise — that affects how their contents are pasted.
:g/./t.\<CR>
The :global command can apply an Ex action to every line that matches a pattern.
:set shiftround
shiftround causes indent commands (>, always adds exactly shiftwidth spaces to whatever indentation the line already has With shiftround: > rounds up to the nex
:set grepformat=%f:%l:%c:%m
When :grep output does not land cleanly in quickfix, the parser format is usually the missing piece.
:/start/,/end/s/pattern/replacement/g
You can restrict a substitution to a range defined by two patterns.
:%s/pattern/\=expr/g
Prefixing the replacement field of :s with \= tells Vim to evaluate the rest as a Vimscript expression and use its result as the replacement string.
qagUiwWq2@a
Macros are most powerful when they encode both the edit and the movement to the next target.
:%normal @q
To apply a macro to every line in the file, use :%normal @q.
:'<,'>sort!
The sort! command sorts the selected lines in reverse (descending) order.
qq;.q then @q or @@
The dot command (.
:%s/\v<(\w)(\w*)>/\u\1\L\2/g
When you need to normalize casing across headings, labels, or generated docs, editing words one by one is tedious.
:g/^/m 0
This clever use of the :global command reverses every line in the current buffer.
command-line #editing #ex-commands #global #text-manipulation
:g/pattern/m$
The :g (global) command combined with :m (move) relocates all matching lines to a specified destination.
command-line #command-line #ex-commands #global #editing #organization
:let @q .= "A;\<Esc>"
If a recorded macro is almost correct but missing a final step, re-recording from scratch is slow and error-prone.