How do I fix the indentation of selected lines in Visual Studio

hugomg picture hugomg · Sep 30, 2011 · Viewed 153.8k times · Source

In vim I can use = to reindent badly indented lines so

foo;
  bar;
 baz;

becomes

foo;
bar;
baz;

Is there an equivalent keyboard-shortcut for visual studio? Where can I find a list of such shortcuts for future reference?


Edit: Is there a way to do fix just the horizontal indentation? There are some cases where the CTRLK,CtrlF is "fixing" too much. (In the meantime I'll see if I can edit the formatting options to my satisfaction...)

Answer

user405725 picture user405725 · Sep 30, 2011

Selecting all the text you wish to format and pressing CtrlK, CtrlF shortcut applies the indenting and space formatting.

As specified in the Formatting pane (of the language being used) in the Text Editor section of the Options dialog.

See VS Shortcuts for more.