Search code examples
visual-studio-codeindentation

How to indent/format a selection of code in Visual Studio Code?


I want to indent a specific section of code in Visual Studio Code.

I read How do you format code in Visual Studio Code? that gives shortcuts to indent the whole code, but it doesn't work when selecting a specific section of code.

I tried Ctrl + Shift + F after selecting some line in my code, but the whole file is indented. I'm on Windows with Visual Studio Code Insider 1.8.0. How can I do it?


Solution

  • I want to indent a specific section of code in Visual Studio Code:

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

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

    • Select the lines you want to format.
    • Use Ctrl + K, Ctrl + F to format them.