VS開発C++コードフォーマット(AStyle)


一.Astyleプラグインのダウンロード
ダウンロード先:https://marketplace.visualstudio.com/items?itemName=Lukamicoder.AStyleExtension
二.AStyleのインストール
1.AStyleExtensionを開きます.vsix
2.対応するVSバージョンを選択
3.VSを再起動し、ツール->オプションを開きます.AStyle Formatterオプションがある場合は、インストールに成功します.図:
三.AStyleの設定(C++の場合)
1.方法1:コマンドライン(私が使用する方法)
    Edit,    .

    :--style=java -f -U -p -N --mode=c

  save ->   

  ,   ->    -> "Format Document(AStyle)" "Format Selection(AStyle)",          .

PS:関連するショートカットキーを修正する.ツール->環境->キーボード、AStyleと入力し、ショートカットキーを設定します.
2.方法2:Settings、チェックを行い、Command lineを生成する
3.方法3:Importインポート
四:一部の関連パラメータの意味
  :--style=java -f -U -p -N --mode=c

--style=java:       Java,      :ansi .

--mode=c:#        ,C/C++  ,      cs,java 

    
(1) –f  //-F       
               , import public class  、public class      ;

(2) –p  //  
          , =、+、- 。
 :int a=10*60;
     :int a = 10 * 60;

(3) –P  //  
     (   )    。 ,-d          ,-D      。
 :System.out.println(1);    //  -P
     System.out.println( 1 );   //   4   

(4) -U
            。
 :System.out.println( 1 );  // 3   
     System.out.println(1); //3       

(5) -V
 Tab     。

(6) -N
        namespaces。
       ,    :
namespacefoospace
{
class Foo
{
public:
Foo();
virtual ~Foo();
};
}
          :
namespacefoospace
{
    class Foo
        {
    public:
        Foo();
        virtual ~Foo();
    };
}

(7) -n
       ,        .orig  。

———————————————————華麗な分割線———————————————————
五.さらなる補充(特別需要)
1.    4   

--indent=spaces=4

2.           

Add brackets to unbracketed one line conditional statements  (e.g. 'if', 'for', 'while'...).
--add-brackets

3.    TAB   

--convert-tabs

4. preprocessor (#define)        ,            ,(     (  )     )

--indent-preprocessor

5.Attach a pointer or reference operator (* or &) to either the variable type (left) or variable name (right), or place it between the type and name.
*,&        

--align-pointer=type

6.*,&          ,      ,

--align-pointer=name

7.              ==

--pad-oper

8.            

insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
--pad-header

9. if,for,while          ,      ,       ,    

Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
--break-blocks 

10.          ,UNIX   Windows ,

--lineend=windows

11.       UNIX   

--lineend=linux

12.switch case              

--indent-switches

13.        ({  )      ,     

--indent-col1-comments

14.namespace class   public,        

--indent-namespaces

--indent-classes

15.            ,=0   (  ,=1      ,=2      ,=3     

MS visual studio           ,

--min-conditional-indent=1

16.         ,  40,  120,         ()        ,          

--max-instatement-indent=80

ヒント:一般的に1つのプロジェクトグループは設定されたプログラミングスタイルを使用します.