---
title: "Can I automatically indent-align code in Visual Studio?"  
description: "Can I automatically indent-align code in Visual Studio?"  
author: "Steilla Mitchel"  
published: 2023-07-19  
updated: 2023-07-19  
canonical: https://www.mindstick.com/forum/159161/can-i-automatically-indent-align-code-in-visual-studio  
category: "visual studio"  
tags: ["visual studio", "format"]  
reading_time: 2 minutes  

---

# Can I automatically indent-align code in Visual Studio?

Can I automatically indent-align [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) in [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available)?

## Replies

### Reply by Aryan Kumar

Yes, you can automatically indent and align code in [Visual](https://yourviews.mindstick.com/audio/1147/through-the-lens-a-visual-exploration-of-the-world) [Studio](https://answers.mindstick.com/qa/116181/google-launches-workspace-studio-to-create-automated-gemini-powered-agents) Code. There are a few ways to do this.

## 1. Using the keyboard shortcuts

- To indent all lines of code, press **Shift + Alt + F**.
- To align all lines of code, press **Shift + Alt + A**.

## 2. Using the Command Palette

- To open the Command Palette, press **Ctrl + Shift + P**.
- Type "indent" and then select the "Indent All Lines" or "Align All Lines" command.

## 3. Changing the settings

You can also change the default settings so that Visual Studio Code automatically indents and aligns code when you save a file. To do this, open the Settings editor by pressing **Ctrl + ,**. In the settings editor, search for the "editor.formatOnSave" setting. The "editor.formatOnSave" setting controls whether Visual Studio Code should automatically format code when you save a file.

For example, to enable automatic indentation and alignment, you would set the "editor.formatOnSave" setting to true.

Here are the steps on how to automatically indent and align code in Visual Studio Code using the settings:

1. Open the Visual Studio Code app.
2. Open the code file you want to automatically indent and align.
3. Press **Ctrl + ,** to open the Settings editor.
4. In the Settings editor, search for the "editor.formatOnSave" setting.
5. In the "editor.formatOnSave" setting, set the value to true.
6. Save your changes.

Once you have saved your changes, Visual Studio Code will automatically indent and align code when you save the file.


---

Original Source: https://www.mindstick.com/forum/159161/can-i-automatically-indent-align-code-in-visual-studio

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
