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...)
This question is related to
visual-studio-2010
keyboard-shortcuts
For the Mac users.
For selecting all of the code in the document => cmd+A
For formatting selected code => cmd+K, cmd+F
Selecting the text to fix, and CtrlK, CtrlF shortcut certainly works. However, I generally find that if a particular method (for instance) has it's indentation messed up, simply removing the closing brace of the method, and re-adding, in fact fixes the indentation anyway, thereby doing without the need to select the code before hand, ergo is quicker. ymmv.
I like Ctrl+K, Ctrl+D, which indents the whole document.
To fix the indentation and formatting in all files of your solution:
2
);This will recursively open and save all files in your solution, setting the indentation you defined above.
You might want to check other programming languages tabs (Options...) for Code Style > Formatting as well.
Source: Stackoverflow.com