Transform text to Uppercase or Lowercase in VS Code

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
3 min

banner

# Table of Contents

  1. Transform text to Uppercase or Lowercase in VS Code
  2. Setting Keyboard shortcuts to transform text to Uppercase or Lowercase

# Transform text to Uppercase or Lowercase in VS Code

To transform text to uppercase or lowercase in VS Code:

  1. Select the text you want to transform.
  2. Press:
  • Ctrl + Shift + P on Windows and Linux
  • Command + Shift + P on macOS
Note: you can also press F1 to open the Command Palette.
  1. Type transform to and select Transform to Uppercase or Transform to Lowercase.

transform to uppercase or lowercase

Note: Make sure to select the text before running the transform command.

Here is a short clip that shows how to transform text to uppercase.

change text to uppercase

And, here is a clip that changes the selected text to lowercase.

change text to lowercase

The same approach can be used to transform the selected text to:

  • Title Case - All words are capitalized, except for minor words.
  • Camel Case - Writing phrases without spaces or punctuation and with capitalized words.
  • Kebab Case - Words are separated by a hyphen.
  • Snake Case - Words are separated by an underscore.

Here is an example that transforms the selected text to Title Case.

transform text to title case

# Setting Keyboard shortcuts to transform text to Uppercase or Lowercase in VS Code

If you need to set keyboard shortcuts to transform text to uppercase or lowercase:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Keyboard Shortcuts and select Preferences: Open Keyboard Shortcuts.

preferences open keyboard shortcuts

  1. Type transformTo in the search field.

set keyboard shortcut transform uppercase lowercase

  1. Double-click on Transform to Lowercase, specify a key combination and press Enter to confirm.
  2. Double-click on Transform to Uppercase, specify a key combination and press Enter to confirm.

You can also hover over the line and click on the plus icon to add a keyboard shortcut.

click plus icon to add keyboard shortcut

For example, I use the Ctrl + Shift + U keyboard shortcut to change text to uppercase and the Ctrl + Shift + U keyboard shortcut to transform text to lowercase.

set custom keyboard shortcuts to change text case

Here is a short clip that demonstrates what using the keyboard shortcuts looks like.

using custom keyboard shortcuts to change text case

# Setting Keyboard shortcuts directly in your keybindings.json file

Alternatively, you can set the keyboard shortcuts directly in your keybindings.json file:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Keyboard Shortcuts and select Preferences: Open Keyboard Shortcuts.

preferences open keyboard shortcuts

  1. Click on the Open Keyboard Shortcuts (JSON) icon to the left.

open keyboard shortcuts

  1. Add the following object to your keybindings.json file.
keybindings.json
[ { "key": "ctrl+shift+u", "command": "editor.action.transformToUppercase", "when": "editorTextFocus" }, { "key": "ctrl+shift+l", "command": "editor.action.transformToLowercase", "when": "editorTextFocus" } ]

You can also set the keybindings to "cmd+shift+u" and "cmd+shift+l" if you are on macOS.

Here is what my keybindings.json file looks like.

setting shortcuts in keybindings json

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.