Back to articles

Visual Mode in Vim

Computer TechDevelopmentEditorsNeovimVisual Mode in Vim
Updated 4/23/2026

Visual Mode in Vim

Visual mode enables text selection in Vim. Unlike normal mode where commands operate on text objects, visual mode highlights text first, then applies operations to the selection.

Three Visual Mode Types

ModeKeySelection TypePrimary Use Case
VisualvIndividual charactersPrecise selections, partial lines
Visual LineVEntire linesCode blocks, whole lines
Visual Block⌃VRectangular columnsAligned data, column editing

Visual Mode (v) - Character Selection

Press v to enter character-wise visual mode.

Selection behavior:

  • Starts at cursor position
  • Expands character by character as cursor moves
  • Can span multiple lines
  • Selects partial lines

Example:

This is line one
This is line two
This is line three

With cursor on "line" in line one, pressing v then moving right selects:

This is [line] one

Moving down includes characters across lines:

This is [line one
This is line t]wo

Use cases:

  • Selecting part of a word
  • Selecting specific text spanning multiple lines
  • Precise selections where line boundaries don't matter

Visual Line Mode (V) - Full Line Selection

Press V (Shift+v) to enter line-wise visual mode.

Selection behavior:

  • Always selects complete lines
  • Cursor position on line doesn't matter
  • Expanding selection adds entire lines
  • Cannot select partial lines

Example:

function hello() {
  console.log("hello");
  return true;
}

With cursor anywhere on line 2, pressing V selects:

function hello() {
[  console.log("hello");]
  return true;
}

Moving down adds entire lines:

function hello() {
[  console.log("hello");
  return true;]
}

Use cases:

  • Copying function definitions
  • Deleting code blocks
  • Moving entire lines
  • Most common for code editing

Visual Block Mode (⌃V) - Rectangular Selection

Press ⌃V (Control+v) to enter block-wise visual mode.

Selection behavior:

  • Selects same column position across lines
  • Creates rectangular selection
  • Width determined by horizontal movement
  • Height determined by vertical movement

Example:

Name:    John
Age:     30
City:    LA
State:   CA

Starting on "J" in "John", pressing ⌃V then moving down and right:

Name:    [John]
Age:     [30  ]
City:    [LA  ]
State:   [CA  ]

Use cases:

  • Editing aligned columns
  • Adding same text to multiple lines
  • Commenting multiple lines (add // to column)
  • Working with CSV/TSV data

Visual Mode Operations

Once text is selected, press an operator key:

Copy and Paste

  • y - Yank (copy) selection
  • d - Delete selection (also copies to register)
  • p - Paste after cursor
  • P - Paste before cursor

Modification

  • c - Change (delete and enter insert mode)
  • r - Replace all selected characters with one character
  • ~ - Toggle case
  • u - Make lowercase
  • U - Make uppercase

Formatting

  • = - Auto-indent selection
  • > - Indent right
  • < - Indent left
  • gq - Format/wrap text

Advanced

  • : - Run Ex command on selection (automatically adds '<,'>)
  • ! - Filter through external command
  • J - Join lines (remove line breaks)

Entering and Exiting

Entering visual mode:

  • v - Character-wise from cursor
  • V - Line-wise from cursor
  • ⌃V - Block-wise from cursor
  • gv - Re-select previous visual selection

Exiting visual mode:

  • Esc - Exit without action
  • Any operator (y, d, c, etc.) - Perform action and exit
  • v (when in v mode) - Toggle back to normal mode
  • V (when in V mode) - Toggle back to normal mode
  • ⌃V (when in ⌃V mode) - Toggle back to normal mode

Visual Mode Indicators

When in visual mode, the bottom of the screen displays:

  • -- VISUAL -- - Character mode
  • -- VISUAL LINE -- - Line mode
  • -- VISUAL BLOCK -- - Block mode

Switching Between Visual Modes

While in any visual mode, press a different visual mode key to switch:

Example:

  1. Press v (character mode) - -- VISUAL --
  2. Press V (switch to line mode) - -- VISUAL LINE --
  3. Press ⌃V (switch to block mode) - -- VISUAL BLOCK --

The selection persists but changes type.

Common Patterns

Select entire function

V     " Enter visual line mode
%     " Jump to matching brace (selects function body)

Select inside quotes/brackets

vi"   " Select inside double quotes
vi'   " Select inside single quotes
vi(   " Select inside parentheses
vi{   " Select inside braces

Select around quotes/brackets (includes delimiters)

va"   " Select around double quotes
va'   " Select around single quotes
va(   " Select around parentheses
va{   " Select around braces

Visual Mode vs Text Objects

Visual mode: Highlight first, then operate

vjjd  " Visual mode, down 2 lines, delete

Text objects: Operate directly without highlighting

d2j   " Delete current line plus 2 down (no visual feedback)

Both achieve the same result. Visual mode provides visual feedback before committing to the action.

Official Vim Documentation