Answer a question

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

In full 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 VISUAL STUDIO CODE WHEN THIS QUESTION WAS ASKED (5 OR MORE YEARS AGO) HAS CHANGED.

Answers

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.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐