How to Change or Switch the Case of Characters in Vim

John John (304)
3 minutes

Need to change the case of characters to all caps or all lowercase? This is easily done using Vim. This guide will show you how to change the case of characters in Vim.


Toggle "Hello" to "hELLO" with g~. Uppercase "Hello" to "HELLO" with gU. Lowercase "Hello" to "hello" with gu.


Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

Select the text you're interested in

Before changing case, you'll need to select the text you're interest in.

To do this, start on the first character you want to toggle, then enter visual mode by typing v. Use the directional keys (h, j, k, l) to select the rest of the text you want to change.

Toggle case

To toggle the case type g~.

All uppercase

If you want to make the text all uppercase use gU.

All lowercase

If you want to make the text all lowercase use gu.

Dayne Dayne (57)

You probably already know how to use vim's basic undo and redo features. For a quick refresher, read this short tutorial on how to use vim redo and undo.