vi批量转换“{”结尾的代码风格到“{”另起一行的代码风格

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xuzhina/article/details/48246395
 const IfMgrIfAtom* ifa = _rm->iftree().find_interface(ifname);
    if (ifa == NULL) {
    ZSP_WARN("Got update for interface not in the libfeaclient tree: %s",
             ifname.c_str());
    return;
    }

    const IfTreeInterface* ifp = observed_iftree().find_interface(ifname);
    if (ifp == NULL) {
    ZSP_WARN("Got update for interface not in the FEA tree: %s",
             ifname.c_str());
    return;
    }

需要改成:


 const IfMgrIfAtom* ifa = _rm->iftree().find_interface(ifname);
    if (ifa == NULL) 
   {
    ZSP_WARN("Got update for interface not in the libfeaclient tree: %s",
             ifname.c_str());
    return;
    }

    const IfTreeInterface* ifp = observed_iftree().find_interface(ifname);
    if (ifp == NULL) 
    {
    ZSP_WARN("Got update for interface not in the FEA tree: %s",
             ifname.c_str());
    return;
    }

用正则表达式:

:s/\([^ \t].*\){/\1\r{/g
 就可以全部替换。 
 

其中

[^ \t].*:是把只有空格,TAB的行过滤掉

\([^ \t].*\):把{前面的内容记录下来

\1\r:在{前面加换行符

猜你喜欢

转载自blog.csdn.net/xuzhina/article/details/48246395