How to switch text case in visual studio code

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to switch text case in visual studio code



How does one switch the case of highlighted text in Visual Studio Code? VS allows this via CTRL+SHIFT+U and CTRL+U.



Is there a command binding that I can set up to do this, or is it by default some other key combination?





I can't find any relevant shortcuts in key bindings. Probably this function is not supported in the current version.
– yushulx
May 18 '15 at 3:27





Update: it is supported now. Go to File > Preferences > Keyboard Shortcuts and search for "Transform".
– Dinei
May 8 '17 at 16:16




5 Answers
5



Echoing justanotherdev's comment:



Mind-blowing and useful:


Ctrl


shift


p


>transform



enter image description here





It's possible to configure keybindings for this commands on File > Preferences > Keyboard Shortcuts
– Dinei
May 8 '17 at 15:59



I've written a Visual Studio Code extension for changing case (not only upper case, many other options): https://github.com/wmaurer/vscode-change-case



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 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.


editor.action.transformToUppercase


editor.action.transformToLowercase



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





the "ctrl+t u" didn't work for me on the mac version. I used "ctrl+u" instead as it's not mapped by default to any action.
– Shahar
Jan 5 '17 at 8:23





For lazy people: select the text, ctrl + p, type >transform pick lower or upper case then press enter
– justanotherdev
Mar 23 '17 at 5:49




>transform





good stuff - thanks...
– chadbr
Apr 19 '17 at 22:28





An addendum to @justanotherdev's comment: it's possible to configure keybindings for this commands on File > Preferences > Keyboard Shortcuts
– Dinei
May 8 '17 at 15:59



Quoted from this post:



The question is about how to make CTRL+SHIFT+U work in Visual Studio
Code. Here is how to do it. (Version 1.8.1 or above). You can also choose a different key combination.



File-> Preferences -> Keyboard Shortcuts.



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


keybindings.json


[
{
"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.





Cool! This is the answer the question is asking for!
– Nowdeen
Nov 19 '17 at 15:53





This should be the accepted answer, doesn't require extra plugin.
– pdem
Nov 29 '17 at 11:01





I went for cmd+shift+u and cmd+shift+l on macOS. Feels just right.
– theory
Mar 27 at 15:03


cmd+shift+u


cmd+shift+l





For Linux ctrl+shift+u is not working, so instead use key ctrl+u for uppercase & ctrl+l for lowercase
– Jitendra Pawar
May 12 at 5:33



I think this is a feature currently missing right now.



I noticed when I was making a guide for the keyboard shortcut differences between it and Sublime.



It's a new editor though, I wouldn't be surprised if they added it back in a new version.



Source: https://code.visualstudio.com/Docs/customization



To have in Visual Studio Code what you can do in Sublime Text ( CTRL+K CTRL+U and CTRL+K CTRL+L ) you could do this:



Between the brackets add:



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



Save and close "keybindings.json"






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

s2HEH9wGzGOh6
Met,lGvqKhIlO v6FNUnY,joU7OfBGu8 DxLG3R8oL

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham