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

How do I uppercase or lowercase the entire current line in one keystroke?

Answer

gUU

Explanation

The gUU command uppercases every character on the current line instantly — no visual selection or motion required. It follows the same doubling pattern as dd, yy, and cc: pressing the operator's motion key twice applies it to the whole line.

How it works

  • gU is the "make uppercase" operator
  • The second U acts as a shorthand for the current-line text object, applying gU to the entire line

The same pattern gives you three case-change variants:

Command Effect
gUU Uppercase the whole line
guu Lowercase the whole line
g~~ Toggle case of every character on the line

Example

Given this line with the cursor anywhere on it:

hello world

Pressing gUU produces:

HELLO WORLD

Pressing guu on that result restores:

hello world

Tips

  • Use gU{motion} to uppercase a region, e.g. gUiw uppercases the word under the cursor
  • guu is the counterpart to gUU — both accept counts: 2guu lowercases two lines
  • The same doubling trick applies to gu and g~: guu, g~~ all work without a separate motion

Next

How do I jump to the Nth line from the top or bottom of the visible screen using a count with H and L?