How do I duplicate the current line to the end of the file without yanking or moving the cursor?
The Ex command :.
category:
editing
tags:
#editing
#ex-commands
#copy
#ranges
How do I insert an actual newline in a substitution replacement, and why does backslash-n not work?
In Vim substitutions, \r in the replacement string inserts a line break, creating a new line.
category:
editing
tags:
#editing
#search
#substitute
#newline
#regex
How do I navigate to an older undo state that is not on my current undo branch?
Vim's undo history is a tree, not a linear stack.
category:
editing
tags:
#undo-redo
#navigation
#normal-mode
How do I hard-wrap a paragraph to fit within textwidth without moving my cursor away from it?
The gw operator reformats text to fit within 'textwidth' — identical in effect to gq, but with one key difference: the cursor returns to its original position
category:
editing
tags:
#editing
#formatting
#text-objects
#normal-mode
How do I use a count with a text object to operate on multiple words, sentences, or paragraphs at once?
Most Vim users know you can put a count before an operator (3dw) or use a text object once (daw).
category:
editing
tags:
#text-objects
#editing
#delete
#normal-mode
#motions
How do I replace only the current match and then stop when doing an interactive substitution in Vim?
l (in :%s///gc confirm prompt)
When running an interactive substitution with the c flag (e.
category:
editing
tags:
#search
#editing
#substitution
#ex-commands
#normal-mode
How do I format and pretty-print JSON in the current Vim buffer using Python?
When editing JSON files in Vim, you can pipe the entire buffer through Python's built-in json.
category:
editing
tags:
#editing
#formatting
#ex-commands
#json
#shell
How do I force-convert all indentation including tabs in the middle of lines throughout an entire file?
The :retab command converts leading whitespace according to the current tabstop and expandtab settings, but it only touches indentation at the start of lines.
category:
editing
tags:
#editing
#indentation
#formatting
#ex-commands
How do I use a count with text objects to operate on multiple text objects at once?
Text objects in Vim accept a count, letting you operate on a span of multiple adjacent text objects in one command.
category:
editing
tags:
#editing
#text-objects
#normal-mode
How do I close all folds and then open just the one containing the cursor to focus on it?
The zMzv sequence collapses every fold in the file and then re-opens only the one containing your cursor.
category:
editing
tags:
#folding
#navigation
#normal-mode
How do I paste text before the cursor while leaving the cursor positioned after the pasted content?
The gP command works like P (paste before the cursor) but leaves your cursor after the pasted text rather than at its beginning.
category:
editing
tags:
#editing
#paste
#registers
#normal-mode
How do I undo all changes made in the last N minutes using time-based undo?
Vim's :earlier command lets you travel back through the undo history by wall-clock time rather than by the number of changes.
category:
editing
tags:
#undo-redo
#editing
#ex-commands
How do I center text on the current line using a built-in Vim command?
Vim has three built-in ex commands for text alignment that most users never discover: :ce (center), :ri (right-justify), and :le (left-justify).
category:
editing
tags:
#editing
#formatting
#ex-commands
#text-formatting
How do I toggle a fold and all its nested folds open or closed at once?
The zA command toggles the fold under the cursor together with all nested sub-folds in one keystroke.
category:
editing
tags:
#folding
#editing
#normal-mode
How do I hard-wrap or reformat a paragraph to fit the current textwidth?
The gq{motion} operator reformats text to fit within Vim's textwidth setting, inserting hard line breaks where lines are too long.
category:
editing
tags:
#editing
#formatting
#motions
#normal-mode
How do I jump directly to a specific point in the undo history by change number?
:undo {N} lets you jump directly to the undo tree state after change number N was applied.
category:
editing
tags:
#undo-redo
#editing
#advanced
How do I type special characters and symbols using Vim's built-in digraph system in insert mode?
Vim's digraph system lets you insert special characters, accented letters, and symbols by typing a memorable two-character sequence.
category:
editing
tags:
#insert-mode
#special-characters
#unicode
#editing
How do I center, right-align, or left-align lines of text using Ex commands?
Vim has built-in Ex commands to align text: :center, :right, and :left.
category:
editing
tags:
#editing
#formatting
#ex-commands
#text-objects
How do I move the cursor in insert mode without creating an undo break point?
By default, moving the cursor with arrow keys while in insert mode creates an undo break — meaning a subsequent u will undo only back to when you last moved,
category:
editing
tags:
#insert-mode
#undo-redo
#editing
#advanced
How do I replace a character while preserving screen column alignment when tabs are involved?
The gr{char} command is Vim's virtual replace variant of r{char}.
category:
editing
tags:
#editing
#normal-mode
#replace
#tabs