In Visual Studio Code how to set up to indent code automatically?

Asked

Viewed 5,311 times

3

1 answer

6


You can do it in two ways by indenting the document as a whole, or just a selected block of code.

The shortcuts below work in VS Code for Windows, for the other OS consult the links

To indent the whole document

If you want to format the entire document you press Shift+Alt+F

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui


To indent a selection made in the code block

If you want to format only a block of code first you have to select it with the mouse, and then you press Ctrl+K Ctrl+F

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui


If you choose extensions...

I recommend the Beautify which you can find at VS Code Market Place. https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify

Or Prettier depending on the code you want to format... https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

Browser other questions tagged

You are not signed in. Login or sign up in order to post.