How do I create a custom undo checkpoint while in Insert mode so I can undo in smaller steps?
<C-g>u
By default, Vim treats an entire Insert mode session (from entering Insert mode to pressing ) as a single undo unit.
2125 results for "i" a""
<C-g>u
By default, Vim treats an entire Insert mode session (from entering Insert mode to pressing ) as a single undo unit.
<C-v><Tab>
When expandtab is set, pressing the Tab key inserts spaces instead of a real tab character.
:sandbox {cmd}
The :sandbox command modifier executes any Ex command in a restricted environment where potentially dangerous operations are blocked.
:while search('TODO') | normal! @q | endwhile
A fixed count like 100@q is brittle: sometimes your macro needs 12 passes, sometimes 300, and over-running can corrupt already-processed text.
macros #macros #automation #search #normal-mode #ex-commands
<C-w>g<C-]>
Pressing g jumps to the definition of the tag under the cursor — just like — but opens the destination in a new horizontal split window.
<C-f> (from command-line)
When you are already in the middle of typing a command (after pressing :) and realize you need to compose something complex — a long substitution, a multi-pip
gqap
The gq operator reformats text by wrapping lines to fit within the textwidth setting.
<C-w>n
n creates a new empty buffer and opens it in a horizontal split above the current window.
:execute "normal! \<{key}>"
When building dynamic :execute normal! calls in Vimscript, you must use double-quoted strings with the \ notation so Vim interprets the special key codes.
<C-v>selection c
In visual block mode, pressing c changes (replaces) all the text in the selected rectangle.
:center
The :center command pads a line with leading spaces so the text is centered within a given width.
{n}<C-w>>
All four window resize mappings accept an optional count prefix that multiplies the resize amount.
:g/^/m0
The :g/^/m0 command is a clever use of Vim's global command to reverse every line in the file.
:%s/\(\w\+\)/\u\1/g
Vim provides case-conversion atoms in substitute replacements: \u uppercases the next character, \l lowercases it, \U uppercases until \e, and \L lowercases unt
qqq
Pressing qqq in normal mode is the quickest way to empty a macro register.
<C-v>jjr<C-k>12
Visual block mode combined with the replace command and digraph input lets you replace a column of characters with special Unicode characters.
:checkhealth {module}
:checkhealth {module} runs the health check only for the specified module, making it much faster than the full :checkhealth which interrogates every registered
command-line #neovim #diagnostics #debugging #plugins #health
:call setreg('"', @", 'l')
Vim registers carry not just their text content but also a type: charwise (c), linewise (l), or blockwise (b).
<C-a> (command-line mode)
In command-line mode, inserts all completions for the word before the cursor at once, as a space-separated list.
:sb {buffer}
The :sb (short for :sbuffer) command opens a buffer that is already loaded in Vim in a new horizontal split window.