How to Change Case in Vim (to Upper, Lower, etc.)

How to Change Case in Vim (to Upper, Lower or Title)

by Heinz Tschabitscher | Jun 20, 2026 | Useful Tech

Struggling to quickly switch entire words from upper to lower case or just toggle a single character in Vim? Vim’s whims can make changing letter case seem tricky. Find out here how to change case in Vim and Neovim ⤓ (to upper, lower and title case) with confident agility.

How to Change Case in Vim (to Upper, Lower or Title)

⚡ Quick Fix

Toggle current character: Press ~ (tilde).
Make lowercase: Use gu followed by a motion.
Make uppercase: Use gU followed by a motion.
Examples: guw → lowercase current word, gUw → uppercase current word, gUU → uppercase current line, guap → lowercase paragraph

In Normal Mode

Time needed: 1 minute

To change the case of text in Vim or Neovim using normal mode:

  1. Position the cursor on the character, word, line or paragraph you want to change.

  2. Enter normal mode.

    Here’s how: Typically, press Esc to enter normal mode in Vim.

  3. Press G (the lowercase letter g) as the first part of the desired case change command.

    Just one letter: Press ~ (tilde) instead to toggle the case for the current character immediately (from upper to lower or vice versa) and move one character to the right.

  4. Now press U for lower case, Shift U for upper case and ~ to toggle the current case.

    Title case: Using a plugin, Vim also lets you change to title case; see below.

  5. Specify the range to which the change should apply.

    Here’s how: All Vim motion commands work, e.g., w changes until the end of the current word, ap changes the current paragraph and uu or UU (repeating the action itself) changes the entire current line.
    Examples:
    gUaw: Changes the current word to upper case
    guu: Makes the current line all lowercase
    g~i): Toggles case for everything in the closest pair of parentheses
    Their word: Vim includes information on changing case in its documentation.

Vim cAse coMManDs MaSteREd?

⇆ Buy La De Du a tea

Tips help fuel these email and tech how-tos.

Using Visual Mode

Of course, you can also use visual mode to first make the selection and then apply a case change:

  1. Press V for visual mode, Shift V for visual line mode or Ctrl V for visual block mode.
  2. Use the motion keys to select the portion of text you want to edit.
  3. Press U for lowercase, Shift U for uppercase and ~ to toggle.
    Here’s which: see the table below for an overview.

Changing more? How to Search and Replace in Vim
A change gone wrong? How to Undo in Vim

Vim Keys for Case Toggling (to Upper, to Lower, and Switch)

Vim KeyAction
Uto lower case
Shift Uto upper case
~toggle case
Ztitle case (using the Vim Titlecase plugin)

How to Change Case in Vim (to Upper, Lower, etc.): FAQ

Can I toggle the case in Vim insert mode?

Yes.

While Vim does not come with ready-made commands to change case in insert mode, you can add your own mappings easily.

Example: To set up a Ctrl L to toggle case for the previously typed word, add the following to your .vimrc file:

inoremap <C-L> <Esc>g~iw`]a

Then, for instance, type exit_success and press Ctrl L immediately (and without adding whitespace) to toggle case for the whole word and get EXIT_SUCCESS.

How do I make a word uppercase in Vim?

To change a word to uppercase in Vim:

  1. Position the cursor on the word.
  2. Type gUiw in normal mode for uppercase.
    Lower: Type guiw for lowercase.

How do I change an entire paragraph to uppercase in Vim?

To change an entire paragraph to uppercase in Vim and Neovim:

  1. Navigate to the paragraph you want to make uppercase.
  2. Type gUap in normal mode.

Can I switch to title case in Vim?

Using search and replace, you can get a basic version of title case in Vim. To change the first letter of each word to upper case with Vim:

  1. Highlight the portion of text you want to change to title case using visual mode or visual line mode.
  2. Press : for the Vim command line.
  3. Now type s/\(w+)/\u\1\L\2/g to replace the first letter with its uppercase equivalent in each word.
    Example: With a selection, the command line will read :'<,'>s/\(w+)/\u\1\L\2/g.
    Headlines: Note that this does not respect headline capitalization conventions and simply capitalizes each word.
    Alternative: The Vim Titlecase plugin adds a title case operator to Vim that you can use like the other case keys.
  4. Press Enter.

(Tested with Vim 9.0–9.1 and Neovim 0.10–0.12; first published September 2023, last updated June 2026)

Home » Useful Tech » How to Change Case in Vim (to Upper, Lower, etc.)