Search code examples
c++visual-studio-2019editorauto-indent

Visual Studio 2019: Auto Indent


Apologies for the triviality of this problem - I can't seem to find an answer anywhere.

Suppose I have the following block:

int plus(int x, int y)
{
    int z = x + y;% Cursor is here
}

After pressing return, I want the cursor to land here:

int plus(int x, int y)
{
    int z = x + y;
    % Cursor is here
}

But right now, it's landing here:

int plus(int x, int y)
{
    int z = x + y;
% Cursor is here
}

How can I make the editor auto-indent to the beginning of the previous line?


Solution

  • You can set Tools -> Options -> Text editor -> C/C++-> Tabs -> Indenting:Smart in Visual Studio.