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

来源:互联网 发布:电信云计算发展措施 编辑:程序博客网 时间:2024/06/08 16:56
 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:在{前面加换行符

0 0
原创粉丝点击