How do I collapse each paragraph of text into a single long line, removing the hard line breaks within it?
Hard-wrapped text (where each sentence is on its own line) is common in commit messages, email threads, and older documentation.
category:
command-line
tags:
#ex-commands
#editing
#formatting
How do I compare the current buffer to another file using Vim's built-in diff mode without leaving the editor?
:diffsplit {file} opens a file in a horizontal split and immediately activates diff mode, highlighting the differences between both buffers.
category:
buffers-windows
tags:
#buffers
#windows
#editing
How do I convert a word between snake_case, camelCase, MixedCase, and kebab-case with a single keystroke?
The vim-abolish plugin provides cr{type} coercions that instantly convert the word under the cursor to a different naming convention.
category:
plugins
tags:
#editing
#text-objects
#normal-mode
How do I search for a string containing special regex characters like dots or asterisks without escaping them?
Vim's default search mode gives special meaning to characters like .
category:
search
tags:
#search
#regex
#normal-mode
How do I reformat text to fit textwidth without moving the cursor from its current position?
The gw operator reformats text just like gq, but leaves the cursor exactly where it started.
category:
editing
tags:
#formatting
#editing
#normal-mode
#motions
How do I make Vim's indent commands always align to a clean shiftwidth boundary?
shiftround causes indent commands (>, always adds exactly shiftwidth spaces to whatever indentation the line already has With shiftround: > rounds up to the nex
category:
config
tags:
#config
#indentation
#editing
How do I programmatically extend or modify a recorded macro without re-recording it?
:let @a = @a . "\<CR>extra"
Vim stores macros as plain text in registers — the same registers used for yanked text.
category:
macros
tags:
#macros
#registers
#vimscript
How do I run a substitution in Vim without getting an error when the pattern is not found?
:%s/pattern/replacement/ge
The e flag on :substitute silences the "Pattern not found" error that Vim normally reports when a substitution has no matches.
category:
search
tags:
#search
#ex-commands
#substitution
#macros
How do I force any split command to open as a vertical split in Vim?
Vim's :vertical modifier (abbreviated :vert) can be prepended to any Ex command that opens a split window to make it open as a vertical split instead of a horiz
category:
buffers-windows
tags:
#buffers-windows
#windows
#splits
#ex-commands
How do I insert today's date into a Vim buffer using the expression register?
<C-r>=strftime('%Y-%m-%d')<CR>
The expression register ("=) lets you evaluate any Vimscript expression and insert its result inline.
category:
registers
tags:
#registers
#insert-mode
#expression-register
#dates
How do I refresh the diff highlighting in Vim when it becomes stale after editing?
After making edits in a vimdiff session, the diff highlighting can become out of sync with the actual content — showing incorrect change markers or missing hu
category:
buffers-windows
tags:
#buffers-windows
#diff
#editing
How do I make Vim's search stop at the end of the file instead of wrapping back to the top?
By default Vim's wrapscan option is enabled, which causes / and ? searches to wrap silently from the end of the file back to the beginning (and vice versa).
category:
config
tags:
#search
#config
#options
How do I change the filename associated with the current buffer in Vim without saving to disk?
:file {newname} (short form: :f {newname}) changes the filename Vim associates with the current buffer.
category:
command-line
tags:
#buffers-windows
#command-line
#ex-commands
How do I jump to a tag and get an interactive list when multiple definitions exist in Vim?
:tjump {identifier} is the smart tag-jumping command: it jumps directly when there is only one matching tag, but shows an interactive numbered list when multipl
category:
navigation
tags:
#navigation
#tags
#buffers-windows
How do I use an atomic group in a Vim regex to prevent backtracking?
Vim's \@> syntax creates an atomic group in a regular expression.
category:
search
tags:
#search
#regex
#advanced-regex
#performance
How do I open a file in read-only mode so I cannot accidentally modify it?
:view opens a file with the readonly option set, preventing accidental writes.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
How do I autocomplete words from a dictionary file while typing in insert mode?
Vim's insert-mode completion system includes dictionary lookup via .
category:
editing
tags:
#completion
#insert-mode
#editing
How do I close one more level of folds without collapsing all folds at once?
Instead of jumping between fully open (zR) and fully closed (zM), zm and zr let you step through fold levels one at a time.
category:
editing
tags:
#folding
#editing
#normal-mode
How do I append more commands to an existing macro without re-recording it from scratch?
Recording a macro with an uppercase register letter appends to the existing macro in the corresponding lowercase register instead of overwriting it.
category:
macros
tags:
#macros
#registers
#recording
#normal-mode
How do I combine two recorded macros into one without re-recording them from scratch?
Macros in Vim are stored as plain text in named registers.
category:
macros
tags:
#macros
#registers
#ex-commands