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 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 indent the current line without changing local marks in Vim?
When you run editing commands from the command line, Vim usually updates special marks like '[ and '] to the changed text.
category:
editing
tags:
#editing
#ex-commands
#marks
#normal-mode
How do I duplicate every non-blank line in a buffer with one Ex command?
The :global command can apply an Ex action to every line that matches a pattern.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
#search
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 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 merge consecutive edits so they undo in a single step?
By default, separate edits often become separate undo entries, which makes replaying or backing out a multi-part change noisy.
category:
editing
tags:
#editing
#undo-redo
#ex-commands
#refactoring
How do I uppercase a word and then jump back to my exact original cursor position?
When you run an operator like gUiw, Vim can leave your cursor in a slightly different place than where you started.
category:
editing
tags:
#editing
#marks
#motions
#normal-mode
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 prepend // to every line using one Vim command?
When you need to comment a whole block quickly, :global combined with :normal is faster than recording a macro or entering Visual Block mode.
category:
editing
tags:
#editing
#ex-commands
#global
#normal-mode
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
How do I ROT13 only the word under the cursor for quick anonymization?
g? is Vim’s built-in ROT13 operator.
category:
editing
tags:
#editing
#operators
#text-objects
#normal-mode
How do I zero-pad issue numbers without changing the # prefix?
:%s/#\zs\d\+/\=printf('%04d', submatch(0))/g
For log files, changelogs, or issue references, you sometimes need fixed-width numeric IDs without touching surrounding syntax.
category:
editing
tags:
#editing
#ex-commands
#substitute
#regex
#text-processing
How do I align key=value pairs on one line using a substitute expression in Vim?
:s/\v(\S+)\s*=\s*(.*)/\=printf('%-20s = %s', submatch(1), submatch(2))/
When a line contains uneven key = value spacing, quick manual fixes are easy to get wrong.
category:
editing
tags:
#editing
#substitute
#regex
#formatting
How do I target a substitution at the cursor position using \%#?
Most substitutions operate on broad ranges, but sometimes you want a precise edit anchored to where your cursor is right now.
category:
editing
tags:
#editing
#search
#ex-commands
#motions
How do I zero-pad every number in a buffer using one substitute expression?
:%s/\d\+/\=printf('%04d', submatch(0))/g
When you need fixed-width numeric fields, manually editing each number is slow and error-prone.
category:
editing
tags:
#editing
#ex-commands
#formatting
#regex