How do I align columns of text into a neatly formatted table in Vim?
When working with data that has uneven spacing — such as variable assignments, CSV-like data, or configuration entries — you can select the lines and pipe t
category:
visual-mode
tags:
#visual-mode
#editing
#formatting
#external-command
#alignment
How do I switch between character, line, and block visual selection without reselecting?
v / V / <C-v> (while in visual mode)
When you are already in visual mode and realize you need a different selection type, you do not have to exit and re-enter.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I reformat a paragraph or visual selection to fit a specific line width?
The gq operator reformats text to fit within your configured textwidth.
category:
visual-mode
tags:
#visual-mode
#formatting
#editing
#text-objects
How do I append text to the end of multiple lines of different lengths?
When you need to append text to the end of several lines that have different lengths, visual block mode with $ is the key.
category:
visual-mode
tags:
#visual-mode
#editing
#block-mode
#insert-mode
How do I append text to the end of multiple lines that have different lengths?
Visual block mode normally selects a fixed-width column, which makes appending tricky when lines have different lengths.
category:
visual-mode
tags:
#visual-mode
#editing
#insert-mode
How do I move the cursor to the other end of a Visual selection in Vim?
When you make a Visual selection in Vim, the cursor sits at one end while the other end is anchored.
category:
visual-mode
tags:
#visual-mode
#editing
#navigation
#motions
How do I progressively expand or contract a visual selection by text objects?
In visual mode, repeating text object motions progressively expands the selection.
category:
visual-mode
tags:
#visual-mode
#text-objects
#selection
#motions
How do I indent lines multiple times without reselecting in visual mode?
Normally, pressing > in visual mode indents the selection but exits visual mode, requiring you to press gv to reselect.
category:
visual-mode
tags:
#visual-mode
#indentation
#mapping
#editing
How do I yank a visual selection to a specific named register?
Using named registers with visual mode lets you store multiple independent snippets simultaneously.
category:
visual-mode
tags:
#visual-mode
#registers
#yank
#clipboard
How do I see a live preview of substitutions as I type in Neovim?
Neovim's inccommand option provides real-time visual feedback as you type substitution commands.
category:
visual-mode
tags:
#visual-mode
#substitute
#neovim
#preview
How do I replace a visual block selection with digraph or special characters?
Visual block mode combined with the replace command and digraph input lets you replace a column of characters with special Unicode characters.
category:
visual-mode
tags:
#visual-mode
#digraph
#unicode
#block-mode
How do I transform text in a visual selection using awk or sed?
:'<,'>!awk '{print toupper($0)}'
Vim can pipe any visual selection through external Unix commands and replace the selection with the output.
category:
visual-mode
tags:
#visual-mode
#external-command
#awk
#text-transformation
How do I convert between tabs and spaces in a visual selection?
The :retab! command converts between tabs and spaces based on your expandtab setting.
category:
visual-mode
tags:
#visual-mode
#indentation
#tabs
#whitespace
How do I ROT13 encode text using visual mode in Vim?
Vim has a built-in ROT13 encoding operator accessible via g?.
category:
visual-mode
tags:
#visual-mode
#encoding
#rot13
#text-transformation
How do I align columns in a visual selection using an external command?
:'<,'>!awk '{printf "%-20s %s\n", $1, $2}'
By piping a visual selection through awk with printf formatting, you can align columns to fixed widths.
category:
visual-mode
tags:
#visual-mode
#formatting
#alignment
#external-command
How do I append text at the end of lines with different lengths using visual block?
When lines have varying lengths, a normal visual block selection stops at the shortest line.
category:
visual-mode
tags:
#visual-mode
#editing
#block-mode
#append
How do I insert sequential line numbers using visual block mode?
<C-v>jjI\=printf('%02d ', line('.')-line("'<")+1)<CR><Esc>
By combining visual block insert with Vim's expression register, you can insert dynamically computed line numbers at the start of each selected line.
category:
visual-mode
tags:
#visual-mode
#block-mode
#line-numbers
#expression-register
How do I move a column of text to a different position using visual block mode?
Visual block mode lets you select, cut, and paste rectangular columns of text.
category:
visual-mode
tags:
#visual-mode
#block-mode
#columns
#editing
How do I select a rectangular block past the end of shorter lines in visual block mode?
By default, Vim's visual block mode () is limited by line length — if some lines are shorter than others, the block selection gets ragged.
category:
visual-mode
tags:
#visual-mode
#editing
#config
#indentation
How do I select to the end of each line in visual block mode?
In visual block mode, pressing $ extends the selection to the end of every line, even when lines have different lengths.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode