Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to customize the Visual Studio autoformat?

I'm using Visual Studio to develop a C/C++ library. I would like to know if there is a way to customize the autoformat tool (Ctrl+K,F) so that:

  • It automatically break lines that are bigger than 120 columns

  • Format a function/method parameter the following way:

    void myFunction(int parameterA,
            float parameterB,
            string paramterC)
    
  • Format the brackets the following way:

    void myFunction()
    {
         // Code goes here...
    }
    

To summarize, I want something similar to what Eclipse does with it's autoformat (Ctrl + Shift + F) that can be customized by editing a XML file.

like image 917
Alceu Costa Avatar asked Jul 09 '09 00:07

Alceu Costa


People also ask

How to format your code in Visual Studio Code?

If you are like me and like to have consistency in formatting your code, this is definitely a must to have configuration. By default, you can use VS code formatters with the shortcut Alt+Shift+F but, you can also configure it to format every time you save your file, like this:

How do I personalize Visual Studio for my development style?

You can personalize Visual Studio in various ways to best support your own development style and requirements. Many of your settings roam with you across Visual Studio instances—see Synchronized settings. This article briefly describes different personalizations and where you can find more information.

How to auto format the code when saving a file?

Enables auto formatting of the code when you save a file. Visual Studio supports auto formatting of the code with the CTRL+E,D or CTRL+E,F key shortcuts but with this extension the command 'Format Document' is executed on Save. Thanks Karen ! The Code Formatter is a 3rd party Visual Studio plugin.

How do I customize the Visual Studio for Mac IDE?

For Visual Studio for Mac, see Customize the Visual Studio for Mac IDE. You can choose a default collection of settings that optimizes Visual Studio for your type of development. For more information, see Environment settings. Many personalization options are exposed through the Environment Options dialog box.


1 Answers

If those options are not good enough for you get UniversalIndentGUI it is a frontend for a whole slew of code formatting engines, you should be able to get the style that you want from it

like image 181
Harald Scheirich Avatar answered Oct 20 '22 00:10

Harald Scheirich