How do I normalize curly quotes to straight quotes in the current buffer?
:%s/[“”]/"/ge<CR>:%s/[‘’]/'/ge<CR>
When text comes from docs, email, or CMS exports, it often contains typographic quotes (“”‘’) that break code snippets, Markdown tooling, or shell comma
category:
editing
tags:
#editing
#substitute
#formatting
#text-cleanup
How do I join a wrapped paragraph into one line without manual cursor moves?
When text is hard-wrapped for readability in git diffs or markdown source, you sometimes need the paragraph as a single line for refactoring, search, or export.
category:
editing
tags:
#editing
#visual-mode
#formatting
#text-objects
How do I collapse long runs of blank lines to a single empty line?
When files pass through formatters, generators, or repeated edits, they often accumulate noisy vertical gaps.
category:
editing
tags:
#editing
#substitute
#formatting
#cleanup
How do I insert a register in Insert mode without reindenting each inserted line?
When you paste multiline snippets from a register while in Insert mode, default insertion can trigger indentation and formatting side effects line by line.
category:
registers
tags:
#registers
#insert-mode
#formatting
#indentation
#editing
How do I fully justify a selected text block to a fixed width using Vim's built-in justify plugin?
:packadd justify | :'<,'>Justify 72
Vim can wrap text, but full left-and-right justification is a different task.
category:
plugins
tags:
#plugins
#formatting
#visual-mode
#text-manipulation
How do I join wrapped paragraph lines while keeping blank-line paragraph separators?
When text is hard-wrapped (for example from email, logs, or copied docs), joining entire paragraphs manually is slow and error-prone.
category:
editing
tags:
#editing
#formatting
#ex-commands
#text-manipulation
How do I swap the first two comma-separated fields on each line with one substitute command?
:%s/\v^([^,]+),([^,]+),/\2,\1,/<CR>
When CSV-like data has two columns in the wrong order, manually fixing each line is slow and error-prone.
category:
editing
tags:
#editing
#regex
#ex-commands
#formatting
How do I zero-pad numbers with :substitute using an expression replacement?
:%s/\v(\d+)/\=printf('%04d', submatch(1))/g<CR>
When you need to normalize IDs, ticket numbers, or sequence values, :substitute can do more than plain text replacement.
category:
command-line
tags:
#command-line
#substitute
#regex
#formatting
#ex-commands
How do I convert all numbers to fixed-width zero-padded values in Vim?
:%s/\v\d+/\=printf('%04d', submatch(0))/g
When you need aligned numeric data for logs, IDs, or generated fixtures, manual edits are slow and error-prone.
category:
command-line
tags:
#command-line
#substitute
#regex
#formatting
How do I make Ctrl-A increment 007 as decimal instead of octal?
:set nrformats-=octal\<CR>
If you work with IDs, ticket numbers, or zero-padded counters, Vim's default octal behavior can be surprising.
category:
config
tags:
#config
#editing
#command-line
#formatting
How do I title-case every word in a buffer using one Vim substitution?
:%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.
category:
editing
tags:
#editing
#substitution
#regex
#formatting
How do I remove trailing spaces only within the currently selected visual block?
Sometimes you need to clean alignment artifacts in a rectangular region without touching the rest of each line.
category:
visual-mode
tags:
#visual-mode
#substitution
#regex
#formatting
#editing
How do I swap the first two whitespace-separated columns on every line?
:%s/\v(\S+)\s+(\S+)/\2 \1/<CR>
When you need to flip two fields across a whole file, a single substitution is faster and safer than recording a macro.
category:
editing
tags:
#editing
#substitution
#regex
#ex-commands
#formatting
How do I reindent the whole file without adding extra jump-list entries?
Bulk formatting commands are common in cleanup sessions, but they often leave side effects in your navigation history.
category:
editing
tags:
#editing
#formatting
#ex-commands
#navigation
How do I improve Vim diff readability for moved or reindented code blocks?
:set diffopt+=algorithm:histogram,indent-heuristic
Default diff behavior can produce noisy hunks when code is moved or indentation changes significantly.
category:
config
tags:
#config
#buffers-windows
#ex-commands
#formatting
How do I replace only part of a match in :substitute without capture groups?
When your match has a stable prefix but you only want to replace the trailing segment, \zs is often cleaner than introducing extra capture groups.
category:
search
tags:
#search
#ex-commands
#formatting
#editing
How do I run a search-and-replace across all files in my argument list and only save changed buffers?
:argdo %s/\<old\>/new/ge | update
When you need to apply the same substitution across a curated set of files, :argdo is safer than a broad project-wide command.
category:
command-line
tags:
#command-line
#ex-commands
#search
#buffers
#formatting
How do I remove trailing whitespace without clobbering @/ or showing no-match errors?
:silent keeppatterns %s/\s\+$//e
Trailing whitespace cleanup is a common housekeeping step, but a plain substitution can leave side effects: it can overwrite your last search pattern (@/) and t
category:
command-line
tags:
#command-line
#ex-commands
#editing
#search
#formatting
How do I trim trailing whitespace in a file without polluting jumplist or search history?
:keepjumps keeppatterns %s/\s\+$//e<CR>
Bulk whitespace cleanup is common, but a plain substitution can leave side effects: your last search pattern changes and jump navigation gets noisy.
category:
editing
tags:
#editing
#command-line
#search
#formatting
How do I convert all hexadecimal numbers to decimal in Vim?
:%s/0x\x\+/\=str2nr(submatch(0), 16)/g
When cleaning logs, protocol dumps, or generated code, you may need to normalize 0x.
category:
editing
tags:
#editing
#ex-commands
#formatting
#search