5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Uncrustifyのセッティング (9) ラインスプリット編

Posted at

かなり少ない

Uncrustifyのオプション説明してたら、ここまで来ました。今回は、行の途中に改行を入れて、行分割してきれいなコードにしましょうというオプションについての解説です。

これらのオプションは、たった4つしかありません。

ラインスプリットオプション一覧

項目 説明
code_width コード幅の制限桁数 { number }
ls_for_split_full 長い'for'文を';'の位置でスプリットするかどうか { false, true }
ls_func_split_full 長い関数のプロトタイプ宣言/呼び出しを','の位置でスプリットするかどうか { false, true }
ls_code_width code_widthでスプリットするかどうか (だいたいcode_widthで少しはみ出す場合あり) { false, true }

僕の設定

line_split.cfg
code_width                               = 96
ls_for_split_full                        = true
ls_func_split_full                       = true
ls_code_width                            = true

CODE_WIDTH

コードのカラム数は僕は96桁ですね。
学生の頃は、BSD KernelのTCP/IPのプロトコルスタックとWi-Fiドライバを開発してたので、80カラムが基本だと思っていたのですが。
最近は、ウィンドウシステム上でエディタ使って開発するのが当たり前となりました。
今では「カラム制限なんていらないんじゃない?」って思うようなことも。
それでも、やはり多数のファイルを横に並べて見比べたりしたいと思うと、96桁とか120桁ぐらいがいいのではないかと思うようになりました。

LS_FOR_SPLIT_FULL

ls_for_split_full.cpp
// ls_for_split_full = true
// 必ずしも、このような整形とはならない。
// ただし、他の改行/空行オプションを追加すると、別の改行ルールが適用される。
    for (std::list<int>::iterator* it = my_long_long_list.begin();
         it != my_long_long_list.end();
         ++it)
    {
    }

LS_FUNC_SPLIT_FULL

ls_func_split_full.cpp
// ls_func_split_full = true
// 長いプロトタイプ宣言があったりすと:
void my_long_long_long_function(MyClass& param1, MyClass& param2, MyClass& param3);

// このようにすべての関数宣言内の','の位置で改行を挿入する。
void my_long_long_long_function(MyClass& param1,
                                MyClass& param2,
                                MyClass& param3);

LS_CODE_WIDTH

ls_code_width.cpp
// 行送りがされるらしいが、ルールが適用されているのかどうかよくわからん。
{
    {
        {
            MyClass long_long_variable =
                    long_namespace::
                    so_long_name_class::
                    so_long_name_method(
                        so_long_name_param);
        }
    }
}
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?