Reputation: 3017
In Visual Studio Code, is there any command currently to move the selected text to the left or right?
I'm not talking about indentation btw.
Upvotes: 40
Views: 89777
Reputation: 21
I have add this feature in my vs code using following steps.
Usage : By using this key bind feature we can move selected text move left/right using keyboard shortcut.
Steps to implement this -->
Open VS code.
Press ctrl + p
Press > and search --> Open keyboard shortcuts (JSON)
Filename : keybindings.json
Add this following code as it is.
Restart your vs code once.
{
"key": "alt+shift+left",
"command": "editor.action.moveCarretLeftAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+shift+right",
"command": "editor.action.moveCarretRightAction",
"when": "editorTextFocus && !editorReadonly"
},
Upvotes: 2
Reputation: 1506
Ok, so these answers didn't really help me as I am a beginner, here is what I did.
File->Preferences->Keyboard Shortcuts
.Move Carret Left
and Move Carret Right
and add your desired keys combinations. (2022 update: If searching these terms don't work search the term carret
.)Upvotes: 15
Reputation: 447
Thanks to suggestions here I created custom key binding (ctrl+shift+p -> shortcut json) accordingly:
{
"key": "alt+left",
"command": "editor.action.moveCarretLeftAction",
"when": "editorFocus && editorHasSelection || editorHasMultipleSelections "
},
{
"key": "alt+right",
"command": "editor.action.moveCarretRightAction",
"when": "editorFocus && editorHasSelection || editorHasMultipleSelections"
}
This "when" functionality is nice, ref here
Hmm, strange that "when": "editorFocus && (editorHasSelection || editorHasMultipleSelections)"
doesn't work.. I forgot to write ending ")" and it worked, added it while writing this answer and it stopped functioning.. hm, maybe somebody can point out what is wrong.
Upvotes: 3
Reputation: 61
Add/edit keyboard shortcut:
Upvotes: 5
Reputation: 1437
A workaround for moving a block of text of just one space is to use the "column selection" feature of Visual Studio. here the detailed instruction:
If you need more info on Block Selection in Visual Studio you could easily find information on the official documentation or here: enter link description here Pay attention in the link the shortcut is wrong, at least for me.
For moving the text right and left you can use TAB key:
Upvotes: 65
Reputation: 1681
This feature has been implemented by a pull request some time ago.
To use it you need to bind the editor.action.moveCarretLeftAction
and editor.action.moveCarretRightAction
actions in the keyboard shortcuts editor.
Upvotes: 69