Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move selected text to the left or right in Visual Studio Code

Tags:

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.

like image 651
Mikey Avatar asked Feb 26 '18 15:02

Mikey


People also ask

How do I shift selected text?

Hold down the "Ctrl" key and the "Shift" key. Press the right arrow key to select the word to the right, or press the left arrow key to select the word to the left. Select one character at a time by holding down the "Shift" key and and using either arrow key (right or left).


2 Answers

Moving blocks of text

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:

  • move the cursor at the upper left corner of the block of text you want to shift;
  • click with the mouse holding down shift + alt, on the down left corner of the block of text you want to shift;
  • now you could insert as many spaces as you want.

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.


Indentation

For moving the text right and left you can use TAB key:

  • TAB move the selected text right
  • SHIFT + TAB move the selected text left
like image 101
Stefano Bossi Avatar answered Oct 22 '22 22:10

Stefano Bossi


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.

Animation showing how the solution works

like image 43
apk Avatar answered Oct 22 '22 22:10

apk