468

Can I make a multi-line selection of text all capitals in Visual Studio Code?

In Visual Studio it's Ctrl+Shift+U to do this.

The extension that exists that I have seen only do non-multi-line blocks.

Note: The UI of VSCode has changed since this question was asked .

Thom A
  • 88,727
  • 11
  • 45
  • 75
Warren P
  • 65,725
  • 40
  • 181
  • 316

14 Answers14

713

The question is about how to make CTRL+SHIFT+U work in Visual Studio Code. Here is how to do it in version 1.57.1 or above.

Steps:

  1. Open Visual Studio Code.

  2. Press CTRL+SHIFT+P.

  3. Type

    open keyboard shortcuts
    
  4. Select

    Open keyboard shortcuts (json)

An editor will appear with keybindings.json file. Place the following JSON in there and save:

[
    {
        "key": "ctrl+shift+u",
        "command": "editor.action.transformToUppercase",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+l",
        "command": "editor.action.transformToLowercase",
        "when": "editorTextFocus"
    }
]

Now CTRL+SHIFT+U will capitalise selected text, even if multi line. In the same way, CTRL+SHIFT+L will make selected text lowercase.

These commands are built into VS Code and no extensions are required to make them work.


Update August 2021

There is a UI to see and update keyboard shortcuts:

File-> Preferences -> Keyboard Shortcuts.

  1. Find "Transform to Uppercase":

    enter image description here

  2. Click the + icon.

  3. In the popup, press the desired key combination and hit enter:

    enter image description here

Do the same for lower case.


Note

In the new versions (eg 1.57.x) of VS Code, Ctrl+Shift+L is a shortcut for bulk selecting all selected text occurrences. So you can use another combination, like Ctrl+Shift+/ etc.

informatik01
  • 16,038
  • 10
  • 74
  • 104
Sunil Purushothaman
  • 8,435
  • 1
  • 22
  • 20
258

Whenever you want to do something in VS Code and don't know how, it's a good idea to bring up the command palette with CTRL+SHIFT+P (CMD+SHIFT+P on mac), and try typing in a keyword for you want. Oftentimes the command will show up there so you don't have to go searching the net for how to do something.

Highlight the text you want to uppercase. Then hit CTRL+SHIFT+P to bring up the command palette. Then start typing the word "uppercase", and you'll see the Transform to Uppercase command. Click that and it will make your text uppercase.

user3413723
  • 11,147
  • 6
  • 55
  • 64
  • Use option-x to bring up the command palette on OSX (VSCode v1.27). Even quicker if you're using the Emacs Friendly Keymap: highlight the text, then ^X^U to uppercase, or ^X^L to lowercase (where ^=ctrl). – Trutane Oct 10 '18 at 19:13
  • 18
    I like this answer because it doesn't require a keybinding. – Kyle Jul 10 '19 at 21:32
  • I think this answer is better if you just need the function for a moment. – Pue-Tsuâ Dec 04 '20 at 07:48
70

Creator of the change-case extension here. I've updated the extension to support spanning lines.

To map the upper case command to a keybinding (e.g. CTRL+T+U), click File -> Preferences -> Keyboard shortcuts, and insert the following into the json config:

{
  "key": "ctrl+t ctrl+u",
  "command": "extension.changeCase.upper",
  "when": "editorTextFocus"
}

EDIT:

With the November 2016 (release notes) update of VSCode, there is built-in support for converting to upper case and lower case via the commands editor.action.transformToUppercase and editor.action.transformToLowercase. These don't have default keybindings. They also work with multi-line blocks.

The change-case extension is still useful for other text transformations, e.g. camelCase, PascalCase, snake_case, kebab-case, etc.

Trevor Jex
  • 274
  • 2
  • 15
Wayne Maurer
  • 12,333
  • 4
  • 33
  • 43
27

Update on March 8, 2018 with Visual Studio Code 1.20.1 (mac)

It has been simplified quite a lot lately.
Very easy and straight forward now.

  1. From "Code" -> "Preferences" -> "Keyboard shortcuts"
  2. From the search box just search for "editor.action.transformTo", You will see the screen like: screenshot of keyboard shortcuts setup dialog in Visual Studio Code (mac)

  3. Click the "plus" sign at the left of each item, it will prompt dialog for your to [press] you desired key-bindings, after it showing that on the screen, just hit [Enter] to save.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Billy Qiu
  • 271
  • 3
  • 2
  • Actually this is the best answer -- the functions are already there, and we just need to change the shortcut keys. Others require too many changes. – William Hou Oct 10 '19 at 17:38
22

In Linux and Mac there are not default shortcuts, so try to set your custom shortcut and be careful about don't choose a hotkey used (For example, CTRL+U is taken for uncomment)

  1. File-> Preferences -> Keyboard Shortcuts.
  2. Type 'transfrom' in the search input to find transform shortcuts.
  3. Edit your key combination.

In my case I have CTRL+U CTRL+U for transform to uppercase and CTRL+L CTRL+L for transform to lowercase

enter image description here

Just in case, for Mac instead of CTRL I used

Daniel Delgado
  • 4,813
  • 5
  • 40
  • 48
15

Change letter case in Visual Studio Code

Updated answer

Show All Commands: Ctrl+Shift+P

and start typing "upper" or "lower" whichever command is highlighted, press Enter:

enter image description here

Note 1. The next time you use the function, it is usually enough to type the first letter of "upper" or "lower" words.

Note 2. You can also assign your own shortcut to these functions as they currently don't have any by default:

enter image description here


enter image description here

Original answer from 2017 (no longer valid for newer VSC versions)

To upper case: Ctrl+K, Ctrl+U

and to lower case: Ctrl+K, Ctrl+L.

Mnemonics:

K like the Keyboard

U like the Upper case

L like the Lower case

simhumileco
  • 31,877
  • 16
  • 137
  • 115
  • Doesn't work. May you talk about VS, not VS-code. – Azriel Berger May 20 '21 at 14:32
  • Thanks for your attention, @AzrielBerger. This answer was correct in 2017, now VSC has removed the default keyboard shortcuts for these actions, but I have updated the answer to the current version. – simhumileco May 20 '21 at 17:12
12

I think you can use

  1. Select text
  2. Ctrl+Shift+P
  3. Enter Transform to Uppercase
Rocket Nikita
  • 470
  • 2
  • 7
  • 20
9

Without defining keyboard shortcuts

  1. Select the text you want capitalized

  2. Open View->Command Palette (or Shift+Command+P)

  3. Start typing "Transform to uppercase" and select that option

  4. Voila!

Nicolai Lissau
  • 7,298
  • 5
  • 43
  • 57
7

At Sep 19 2018, these lines worked for me:

File-> Preferences -> Keyboard Shortcuts.

An editor will appear with keybindings.json file. Place the following JSON in there and save.

// Place your key bindings in this file to overwrite the defaults
[
    {
        "key": "ctrl+shift+u",
        "command": "editor.action.transformToUppercase",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+l",
        "command": "editor.action.transformToLowercase",
        "when": "editorTextFocus"
    },

]
David Castro
  • 1,773
  • 21
  • 21
6

I'm using the change-case extension and it works fine. I defined the shortcuts:

{ 
  "key": "ctrl+shift+u", 
  "command": "extension.changeCase.upper", 
  "when": "editorTextFocus" 
},
{ 
  "key": "ctrl+u",
  "command": "extension.changeCase.lower", 
  "when": "editorTextFocus" 
},
simhumileco
  • 31,877
  • 16
  • 137
  • 115
Eve Huguet
  • 81
  • 1
  • 4
2

Standard keybinding for VS Code on macOS:

Selection to upper case +K, +U and to lower case: +K, +L.

All key combinations can be opened with +K +S (like Keyboard Settings), where you can also search for specific key combinations.

creep3007
  • 1,794
  • 2
  • 21
  • 22
2

enter image description here

Select the text to transform.

Use Ctrl + L to selected the whole line

Open Show all commands.

Linux and Windows: Ctrl + Shift + P, Mac: ⇧⌘P

Type in the command, e.g. lower, upper, title

Hit Enter

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
1

On a Mac, in Visual Studio Code, its very easy to add a key binding to perform this action, it is not linked to a hotkey combo as a default though.

  • In the menu bar, navigate to: Code > Preferences > Keyboard Shortcuts
  • In the search bar that comes up, type: Uppercase
  • A entry will come up called "Transform to Uppercase"
  • Hover your mouse over that entry and click the plus sign just to the left of the words "Transform to Uppercase"
  • In the box that comes up push the keys you want to bind that action to (Cmd +Shift + U is taken so I chose Ctrl + Shift + U) then press enter and you're good to go.

Note this is working at the time of this writing in May of 2021

1

there is also a related thread about this where it states (Windows):

Command Palette: CTRL + SHIFT + p (Mac: CMD + SHIFT + p)
type >transform pick upper/lower case and press enter

What is pitty though is that on Notepad++ you are not forced to use the transform function to make simple things like uppercase and lowercase, a simple CTRL + SHIFT + U makes the job very good :)

Andy McRae
  • 525
  • 7
  • 15