How to indent / format code selection in VSCode using ctrl + shift + f

I want to highlight a separate section of code in VSCode

I read How you format the code in a Visual Studio Code (VSCode) message that gives shortcuts for indenting the entire code, but it does not work when you select a specific section of code.

I tried ctrl+shirt+F after selecting some line in my code, but the whole file is indented. I am on Windows with VSCode Insider 1.8.0.

It seems to me that this is possible in an older version of VSCode Insider ..

Any help would be appreciated :)

+6
source share
2 answers

I want to indent specify a specific section of code in VSCode:

  • Select the lines you want to indent,
  • use Ctrl + ] to indent them.

If you want to format the section (instead of indenting it):

  • Select the lines you want to format,
  • use Ctrl + K , Ctrl + F to format them.
+19
source
  • you can also separate the entire section by selecting it and pressing TAB
  • as well as indent back using Shift + TAB

and, of course, to automatically indent and format, following the language you use, you can see what a good extension does a good job, and what forms to install or what options you can enable or set. Every language and tools available. Just be sure to read the extension documentation well to install and install everything you need. So far, the indentation problem has bothered me with python when copying pasting a block of code, if that is how you solve this fooobar.com/questions/1012151 / ....

+7
source

Source: https://habr.com/ru/post/1012148/


All Articles