How do I visually select an entire code block to the matching closing brace?
Pressing V]} in normal mode enters visual line mode and immediately extends the selection to the next unmatched closing brace }.
category:
visual-mode
tags:
#visual-mode
#navigation
#text-objects
#editing
#motions
How do I center-align a block of selected lines at a specific column width in Vim?
After making a visual selection, typing : automatically inserts ' to scope the command to the selection.
category:
visual-mode
tags:
#visual-mode
#formatting
#ex-commands
#indentation
How do I auto-indent a block of code in visual selection without specifying a line range?
Pressing = in visual mode re-indents all selected lines according to the current filetype's indent rules — the same engine used by == for a single line, but a
category:
visual-mode
tags:
#visual-mode
#indentation
#editing
#text-objects
How do I move the cursor to the other corner of a visual block selection?
In visual-block mode (), pressing o moves the cursor to the diagonally opposite corner of the selection, and O moves it to the other end of the same row (flippi
category:
visual-mode
tags:
#visual-mode
#visual-block
#navigation
#editing
How do I toggle, uppercase, or lowercase text using motion commands in Vim?
Vim has three case-change operators that work like any other operator — you can combine them with motions, text objects, or double them to act on the whole li
category:
visual-mode
tags:
#editing
#visual-mode
#normal-mode
#text-objects
How do I insert the same text at the start of multiple lines using visual block mode?
Visual block mode () lets you select a rectangular region across lines.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I switch between charwise, linewise, and blockwise visual mode without losing my selection?
Once you are in any visual mode, pressing v, V, or switches to charwise, linewise, or blockwise visual mode respectively — without cancelling the current sele
category:
visual-mode
tags:
#visual-mode
#normal-mode
#editing
How do I pipe a visual selection through an external shell command and replace it with the output?
After making a visual selection and entering the command line with :, Vim automatically inserts the range ' for the selection.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
#shell
How do I insert text at the beginning of multiple lines at once using visual block mode?
Visual block mode's I command lets you type once and have the text inserted at the cursor column across all selected lines simultaneously.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I reflow and hard-wrap a paragraph or selected lines to a fixed width in Vim?
Pressing gq on a visual selection reformats the selected lines to hard-wrap at textwidth columns.
category:
visual-mode
tags:
#visual-mode
#editing
#formatting
How do I adjust the width of a visual block selection without restarting it?
In visual block mode (), pressing O (uppercase) moves your cursor to the other end of the current line — letting you expand or contract the block's horizontal
category:
visual-mode
tags:
#visual-mode
#visual-block
#selection
#editing
How do I reindent a block of code using a visual selection?
After making a visual selection, pressing = applies Vim's auto-indent to every selected line at once.
category:
visual-mode
tags:
#visual-mode
#indentation
#editing
#formatting
How do I run a normal mode command on every line in a visual selection?
After making a visual selection, :norm {commands} executes normal-mode keystrokes on every line in the range.
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
#normal-mode
How do I replace a visual selection with yanked text in Vim?
In visual mode, pressing p replaces the selected text with the contents of the default register.
category:
visual-mode
tags:
#visual-mode
#editing
#registers
#normal-mode
How do I paste over a visual selection without losing my yanked text?
When you paste over a visual selection using p (lowercase), Vim replaces the selection with your register contents — but the replaced text overwrites your unn
category:
visual-mode
tags:
#visual-mode
#registers
#paste
#editing
How do I move the cursor to the other end of a visual selection without restarting it?
In visual mode, pressing o swaps the cursor between the two ends of the selection (the anchor and the free end).
category:
visual-mode
tags:
#visual-mode
#navigation
#editing
How do I switch between visual mode and select mode in Vim?
Vim has a lesser-known select mode that behaves like selection in typical GUI editors: any typed character replaces the selection.
category:
visual-mode
tags:
#visual-mode
#select-mode
#editing
#normal-mode
How do I change the case of a specific column of text using visual block mode?
Visual block mode lets you select rectangular regions of text, which means you can target a specific column and apply case changes only to that area.
category:
visual-mode
tags:
#visual-mode
#editing
#text-objects
#formatting
How do I turn a visual selection of lines into a numbered list?
:s/^/\=line('.') - line("'<") + 1 . '. '/
When you need to quickly number a set of lines — such as TODO items, steps, or bullet points — you can use a visual selection combined with a substitution e
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
#formatting
#substitute
How do I move the cursor to the other end of a visual selection to adjust it?
When you start a visual selection, the cursor is at one end and the anchor is at the other.
category:
visual-mode
tags:
#visual-mode
#navigation
#editing
#motions