How do I automatically apply the first spelling suggestion without opening the full suggestion list?
The z= command opens an interactive numbered menu of spelling corrections for the word under the cursor, requiring you to type a number and press Enter.
category:
editing
tags:
#editing
#normal-mode
#search
How do I scroll the buffer up or down while staying in insert mode?
<C-x><C-e> and <C-x><C-y>
While in insert mode, scrolls the window up one line and scrolls it down one line — all without leaving insert mode.
category:
editing
tags:
#insert-mode
#editing
#scrolling
How do I open or close every fold in the entire file at once?
When working with a heavily folded file, manually opening or closing each fold is tedious.
category:
editing
tags:
#folding
#navigation
#editing
#normal-mode
How do I trigger a custom user-defined completion function in insert mode?
Vim's invokes a user-defined completion function, letting you plug any completion logic you want into the standard insert-mode completion popup.
category:
editing
tags:
#completion
#insert-mode
#editing
How do I use keyword completion that searches included files and headers in Vim?
Vim's completion mode searches for keyword matches not just in the current buffer, but also in all files reachable via include directives (e.
category:
editing
tags:
#completion
#insert-mode
#editing
How do I undo all changes made since the last time I saved the file in a single step?
The :earlier {count}f command navigates Vim's undo tree to the state of the buffer at the time of the last (or Nth) file write.
category:
editing
tags:
#undo-redo
#ex-commands
#editing
How do I delete a fold definition at the cursor without deleting the underlying text?
zd removes the fold definition at the cursor position — the text inside the fold is not deleted.
category:
editing
tags:
#folding
#editing
#normal-mode
How do I open all nested folds under the cursor at once in Vim?
zO (uppercase O) opens the fold under the cursor and all folds nested inside it recursively.
category:
editing
tags:
#folding
#editing
#normal-mode
How do I center, right-justify, or left-justify lines of text in Vim without a plugin?
:'<,'>center / :'<,'>right / :'<,'>left
Vim has built-in Ex commands to align text within a specified width: :center, :right, and :left.
category:
editing
tags:
#editing
#visual-mode
#formatting
#ex-commands
How do I delete, change, or yank an entire sentence as a text object in Vim?
Vim defines a sentence as text ending with .
category:
editing
tags:
#editing
#text-objects
#delete
#normal-mode
#motions
How do I join a specific range of lines into one line using an Ex command?
The :[range]join Ex command lets you join lines by specifying an explicit line range — without having to navigate there or use visual selection.
category:
editing
tags:
#ex-commands
#editing
#formatting
#normal-mode
How do I remove Windows carriage returns (^M) from a file opened in Vim?
When a file created on Windows is opened in Vim on a Unix system, lines may retain \r (carriage return) characters, displayed as ^M at the end of each line.
category:
editing
tags:
#editing
#search
#ex-commands
#normal-mode
How do I center-align or right-align lines of text in Vim without an external tool?
Vim's built-in :left, :center, and :right Ex commands align text without plugins or external tools.
category:
editing
tags:
#editing
#ex-commands
#formatting
How do I prevent cursor movement in insert mode from splitting the undo block?
inoremap <Left> <C-g>U<Left>
In insert mode, any cursor movement — including arrow keys, Home, and End — causes Vim to split the undo block at that point.
category:
editing
tags:
#insert-mode
#undo-redo
#editing
How do I uppercase or capitalize matched text inside a Vim substitution?
Vim's substitute command supports special case-conversion sequences in the replacement string, letting you transform matched text to upper or lower case without
category:
editing
tags:
#editing
#search
#ex-commands
#normal-mode
How do I run a shell command on a range of lines in normal mode and replace them with the output?
In normal mode, !{motion} sends the lines covered by the motion to a shell command's stdin and replaces them with stdout.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
#formatting
How do I sort lines by their numeric value instead of alphabetically?
:sort n sorts lines by the first number found on each line, comparing values numerically rather than as strings.
category:
editing
tags:
#editing
#ex-commands
#formatting
How do I run a single normal mode command without fully leaving insert mode?
Pressing while in insert mode lets you execute exactly one normal mode command and then automatically returns you to insert mode.
category:
editing
tags:
#insert-mode
#editing
#normal-mode
How do I center, right-align, or left-align lines of text using Vim's built-in Ex commands?
Vim includes three built-in Ex commands for text alignment that most users never discover: :center, :right, and :left.
category:
editing
tags:
#editing
#formatting
#ex-commands
#indentation
How do I complete identifiers using ctags from within insert mode?
Pressing in insert mode opens a completion menu populated from your project's tags file.
category:
editing
tags:
#completion
#insert-mode
#editing