Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Auto-Format Broken

I'm running Visual Studio 2008 sp1 on Windows 7 Build 7100 32bit.

I've never had this problem before, even on different installs of Windows 7 RC.

when I finish a statement with a ';' or '}' or something, normally VS will auto format that line or block of code. It hasn't been for me.

I checked Tools->Options->Text Editor->C#->Formatting->General, and the 3 "Auto Format" check boxes are checked already. When I press the hot key to auto-format, it formats the source as expected.

Anyone have any idea why it's doing this?

What I have installed that might have something to do with this: VS2008 SP1 SQL Server 2008 sp1 Office 2007

Thanks for the help

like image 709
Joel Avatar asked Jul 21 '09 00:07

Joel


People also ask

How do I fix the format in Visual Studio?

As long as your code is syntactically correct (i.e. no stray brackets or End Ifs without matching Ifs), Visual Studio will reformat your whole file with one key chord: Hold down the Control key and then press K, followed by D. Boom! Everything looks pretty again.

How do I fix Visual Studio formatting code?

The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.

How do I enable auto format in VS Code?

VS Code Auto Format On SaveOpen Visual Studio Code editor. Click the “Settings” gear icon in the bottom-left corner. Search “Formatter” and click the “Editor: Default Formatter” option. From the drop-down menu, select whichever code formatter you want to use.


2 Answers

I think I found what I did wrong. I changed the tab settings from Smart to Block. Apparently, the smart tabs setting is what triggers the autocomplete when you close a block or toss in a ;

like image 70
Joel Avatar answered Oct 06 '22 00:10

Joel


@Joel thanks I also have the problem that type; is not automatically formatted. Solution:Text Editor -> C/C++ -> Tabs ->Block

like image 26
Emerson Jiang Avatar answered Oct 05 '22 23:10

Emerson Jiang