vimtricks.wiki Concise Vim tricks, one at a time.

How do I change the case of a specific column of text using visual block mode?

Answer

<C-v>jjlU

Explanation

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. This is extremely useful when working with tabular data, CSV files, or any aligned text where you need to uppercase or lowercase specific columns without affecting the rest of the line.

How it works

  • <C-v> — enters visual block mode, allowing rectangular selection
  • jj — extends the selection down two lines (use as many j presses as needed)
  • l — extends the selection one column to the right (adjust width as needed)
  • U — converts all selected characters to uppercase

You can substitute U with u for lowercase or ~ to toggle case.

Example

Before (cursor on the j of john):

john,doe,engineer
jane,smith,designer
jack,lee,manager

After pressing <C-v>jjlU:

JOhn,doe,engineer
JAne,smith,designer
JAck,lee,manager

Only the first two characters of each line were uppercased because the block selection was two columns wide.

Tips

  • Use $ instead of l to extend the block to the end of each line
  • Combine with motions like f, to select up to a delimiter, then apply U or u
  • Use gU and gu as operators outside of visual mode for motion-based case changes: gUiw uppercases the current word

Next

How do I ignore whitespace changes when using Vim's diff mode?