Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

visual studio code - Make selected block of text uppercase

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Steps

Open Visual Studio Code

Press CTRL+SHIFT+P

Type

open keyboard shortcuts

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.

Find "Transform to Uppercase"

enter image description here

Click the + icon

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 VSC, Ctrl+Shift+L is a shortcut for bulk selecting all selected text occurrences. (You can use another, like Ctrl+Shift+/)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...