How to fix highlighted lines in Visual Studio

In vim, I can use = to fix heavily indented, so

 foo; bar; baz; 

becomes

 foo; bar; baz; 

Is there an equivalent keyboard for Visual Studio? Where can I find a list of such shortcuts for future reference?




Edit: Is there a way to fix only horizontal indentation? There are cases when CTRL K , CTRL F is too tightly β€œfixed”. (In the meantime, I'll see if I can change the formatting options to my satisfaction ...)

+68
visual-studio-2010 keyboard-shortcuts
Sep 30 '11 at 14:16
source share
5 answers

Selecting all the text you want to format and pressing Ctrl K , Ctrl F shortcut applies formatting indents and spaces.

As indicated in the Formatting panel (language used) in the Text Editor section of the Options dialog box.

See VS Short Links for more details.

+112
Sep 30 '11 at 14:21
source share

I like Ctrl + K , Ctrl + D , which indent for the whole document.

+20
Jan 20 '15 at 15:14
source share

Selecting text to fix and Ctrl K , Ctrl F shortcut certainly works. However, I usually find that if a particular method (for example) has indentation, just removing the closing figure of the method and re-adding it actually corrects the indentation, thereby making the ergo faster without having to select a code in front of the hand. YMMV.

+14
Mar 13 '14 at 11:38
source share

For Mac users.

To select all code in a document => cmd + A

To format the selected code => cmd + K , cmd + F

+1
Sep 09 '18 at 5:25
source share

To fix indentation and formatting in all files of your solution:

  1. Install the extension " Format all files" => close VS, run the .vsix file and open VS again;
  2. Menu Tools> Options ...> Text Editor> All Languages> Tabs:
    1. Click on Smart (to resolve conflicts);
    2. Enter the desired tab size and indent size (for example, 2 );
    3. Click on Insert Spaces if you want to replace the tabs with spaces ;
  3. In Solution Explorer ( Ctrl + Alt + L ), right-click any file and select " Format All Files" (bottom) from the menu.

This will recursively open and save all the files in your solution, setting the indent defined by you above.

You might want to check the tabs of other programming languages ​​(Options ...) for Code Style> Formatting.

0
Apr 16 '19 at 16:14
source share



All Articles