在 vim 中,如何在我的文件上运行以下逻辑:
If the line
n
not end with a semicolon, concatenate linesn
andn + 1
.
我的文件损坏了 SQL 语句:
broken version
select * from tab1;
select col4, col5 from
tab5;
insert into
tab6 values(
2, 4);
required version
select * from tab1;
select col4, col5 from tab5;
insert into tab6 values(2, 4);
最佳答案
:v/;$/normal J
您可能需要运行几次。
编辑:这是一个解决多行(>2)行分割问题的解决方案:
%s/^\s*$\|\([^;]\)\s*\n/\1/g
注意:空行被保留,但由于 ^\s*$ 而被修剪
关于vim - 如何在vim中根据条件执行行串联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4278580/