是否可以自定义Visual Studio autoformat?

时间:2022-11-14 08:02:43

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:

我正在使用Visual Studio开发C / C ++库。我想知道是否有一种方法可以自定义autoformat工具(Ctrl + K,F),以便:

  • It automatically break lines that are bigger than 120 columns

    它会自动断开大于120列的行

  • 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.

总而言之,我想要一些类似于Eclipse使用它的autoformat(Ctrl + Shift + F)的东西,可以通过编辑XML文件来自定义。

2 个解决方案

#1


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

如果这些选项不够好你得到UniversalIndentGUI它是一大堆代码格式化引擎的前端,你应该能够从中得到你想要的样式

#2


Tools | Options | Text Editor | C++

工具|选项|文字编辑器| C ++

That is all I know that lets you edit how the code is formatted and the auto formatter uses these options (as few as they are).

这就是我所知道的,它允许您编辑代码的格式,自动格式化程序使用这些选项(尽可能少)。

#1


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

如果这些选项不够好你得到UniversalIndentGUI它是一大堆代码格式化引擎的前端,你应该能够从中得到你想要的样式

#2


Tools | Options | Text Editor | C++

工具|选项|文字编辑器| C ++

That is all I know that lets you edit how the code is formatted and the auto formatter uses these options (as few as they are).

这就是我所知道的,它允许您编辑代码的格式,自动格式化程序使用这些选项(尽可能少)。