我经常遇到像这样的代码
tree->Branch("Regression_Q2_RANDOM",&Regression_Q2_RANDOM,"Regression_Q2_RANDOM/F");
tree->Branch("Regression_Q2_BEST",&Regression_Q2_BEST,"Regression_Q2_BEST/F");
tree->Branch("Regression_Q2_WORST",&Regression_Q2_WORST,"Regression_Q2_WORST/F");
tree->Branch("Regression_Q2_TRUE",&Regression_Q2_TRUE,"Regression_Q2_TRUE/F");
tree->Branch("Regression_Q2_HI",&Regression_Q2_HI,"Regression_Q2_HI/F");
tree->Branch("Regression_Q2_LO",&Regression_Q2_LO,"Regression_Q2_LO/F");
由于排长队,大多数自动格式化程序无论如何都不满意,但除此之外,我希望将函数参数对齐如下:
tree->Branch("Regression_Q2_RANDOM",&Regression_Q2_RANDOM,"Regression_Q2_RANDOM/F");
tree->Branch("Regression_Q2_BEST", &Regression_Q2_BEST, "Regression_Q2_BEST/F");
tree->Branch("Regression_Q2_WORST", &Regression_Q2_WORST, "Regression_Q2_WORST/F");
tree->Branch("Regression_Q2_TRUE", &Regression_Q2_TRUE, "Regression_Q2_TRUE/F");
tree->Branch("Regression_Q2_HI", &Regression_Q2_HI, "Regression_Q2_HI/F");
tree->Branch("Regression_Q2_LO", &Regression_Q2_LO, "Regression_Q2_LO/F");
这样,通过块编辑,我可以用星号替换&符号,或者对参数的公共部分进行其他块操作。 clang-format
(或许是另一个形成者)能做到吗?
奖励积分:
这可能要求太多,但最好也是字符串的公共端应该对齐:
tree->Branch("Regression_Q2_RANDOM",&Regression_Q2_RANDOM,"Regression_Q2_RANDOM" "/F");
tree->Branch("Regression_Q2_BEST", &Regression_Q2_BEST, "Regression_Q2_BEST" "/F");
tree->Branch("Regression_Q2_WORST", &Regression_Q2_WORST, "Regression_Q2_WORST" "/F");
tree->Branch("Regression_Q2_TRUE", &Regression_Q2_TRUE, "Regression_Q2_TRUE" "/F");
tree->Branch("Regression_Q2_HI", &Regression_Q2_HI, "Regression_Q2_HI" "/F");
tree->Branch("Regression_Q2_LO", &Regression_Q2_LO, "Regression_Q2_LO" "/F");