在多行中用相应的元素格式化 C++ 代码
Format C++ code with corresponding elements over multiple lines
我正在寻找一种工具来制作丑陋的方块
if ( str == "str" ) decorator["str"] = &Props::goodstr;
else if ( str == "strM" )
decorator["strM"] = &Props::goodstrM;
else if ( str == "strXL" ) decorator["strXL"] = &Props::goodstrXL;
else if ( str == "strXXXL" ) decorator["strXXXL"] = &Props::goodstrXXXL;
在 vim 中的可视块模式下可以轻松地在多行上编辑的漂亮块:
if ( str == "str" ) decorator["str" ] = &Props::goodstr ;
else if ( str == "strM" ) decorator["strM" ] = &Props::goodstrM ;
else if ( str == "strXL" ) decorator["strXL" ] = &Props::goodstrXL ;
else if ( str == "strXXXL" ) decorator["strXXXL"] = &Props::goodstrXXXL;
或非常相似的内容。
它不必在 vim 中!我只是标记它 vim,因为这是我通常使用的。请推荐其他可以完成这项工作的工具。
我实际上知道一个工具可以帮助对齐所有 "ugly" 块。它被称为Align。你所要做的就是给他你想要对齐的模式。
所以对于上面的代码你可以这样做:
:%normal! ggJ
:%s/;/;\r/g
:%left
:AlignCtrl =Clp1P1IW
:% Align (\|)\|]\|[\|&.\+
:% Align ;
从第 5 个命令可以看出,您需要通过提供模式手动重新组织代码
结果:
if ( str == "str" ) decorator [ "str" ] = &Props::goodstr ;
else if ( str == "strM" ) decorator [ "strM" ] = &Props::goodstrM ;
else if ( str == "strXL" ) decorator [ "strXL" ] = &Props::goodstrXL ;
else if ( str == "strXXXL" ) decorator [ "strXXXL" ] = &Props::goodstrXXXL ;
我正在寻找一种工具来制作丑陋的方块
if ( str == "str" ) decorator["str"] = &Props::goodstr;
else if ( str == "strM" )
decorator["strM"] = &Props::goodstrM;
else if ( str == "strXL" ) decorator["strXL"] = &Props::goodstrXL;
else if ( str == "strXXXL" ) decorator["strXXXL"] = &Props::goodstrXXXL;
在 vim 中的可视块模式下可以轻松地在多行上编辑的漂亮块:
if ( str == "str" ) decorator["str" ] = &Props::goodstr ;
else if ( str == "strM" ) decorator["strM" ] = &Props::goodstrM ;
else if ( str == "strXL" ) decorator["strXL" ] = &Props::goodstrXL ;
else if ( str == "strXXXL" ) decorator["strXXXL"] = &Props::goodstrXXXL;
或非常相似的内容。
它不必在 vim 中!我只是标记它 vim,因为这是我通常使用的。请推荐其他可以完成这项工作的工具。
我实际上知道一个工具可以帮助对齐所有 "ugly" 块。它被称为Align。你所要做的就是给他你想要对齐的模式。
所以对于上面的代码你可以这样做:
:%normal! ggJ
:%s/;/;\r/g
:%left
:AlignCtrl =Clp1P1IW
:% Align (\|)\|]\|[\|&.\+
:% Align ;
从第 5 个命令可以看出,您需要通过提供模式手动重新组织代码
结果:
if ( str == "str" ) decorator [ "str" ] = &Props::goodstr ;
else if ( str == "strM" ) decorator [ "strM" ] = &Props::goodstrM ;
else if ( str == "strXL" ) decorator [ "strXL" ] = &Props::goodstrXL ;
else if ( str == "strXXXL" ) decorator [ "strXXXL" ] = &Props::goodstrXXXL ;