VIM:如何搜索匹配没有特定字符的行?
我从 ldiff 文件中有一些像这样的行,
dn: cn=dkalland_directs_ww,cn=org_groups,cn=beehive_groups,cn=groups,dc=oracle
,dc=com
businesscategory: open
cn: dkalland_directs_ww
description: Directs Group for [email protected]
displayname: dkalland_directs_ww
mail: [email protected]
objectclass: top
objectclass: orclGroup
objectclass: groupOfUniqueNames
orclglobalid: modified
orclnormdn: cn=dkalland_directs_ww,cn=org_groups,cn=beehive_groups,cn=groups,d
c=oracle,dc=com
owner: cn=BHGRPADMIN_WW,L=AMER,DC=ORACLE,DC=COM
uniquemember: cn=mattias_tobiasson,dc=us,dc=oracle,dc=com
uniquemember: cn=mattias_joelson,dc=us,dc=oracle,dc=com
uniquemember: cn=markus_persson,dc=us,dc=oracle,dc=com
...
现在有一些行是前一行的延续。我想和他们一起回到各自的队伍。
我感到困惑的是如何搜索没有 ":"
字符的行,以便我可以将其与上一行连接起来。
请帮忙。
I have some lines like this from an ldiff file,
dn: cn=dkalland_directs_ww,cn=org_groups,cn=beehive_groups,cn=groups,dc=oracle
,dc=com
businesscategory: open
cn: dkalland_directs_ww
description: Directs Group for [email protected]
displayname: dkalland_directs_ww
mail: [email protected]
objectclass: top
objectclass: orclGroup
objectclass: groupOfUniqueNames
orclglobalid: modified
orclnormdn: cn=dkalland_directs_ww,cn=org_groups,cn=beehive_groups,cn=groups,d
c=oracle,dc=com
owner: cn=BHGRPADMIN_WW,L=AMER,DC=ORACLE,DC=COM
uniquemember: cn=mattias_tobiasson,dc=us,dc=oracle,dc=com
uniquemember: cn=mattias_joelson,dc=us,dc=oracle,dc=com
uniquemember: cn=markus_persson,dc=us,dc=oracle,dc=com
...
Now as there are some lines which are continuation of the previous line. I want to join them back to their respective line.
What I am confused about is how can I search a line without the ":"
character so that I can join it with previous line.
Plz help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您想要执行
v
命令选择与模式/:/
不匹配的所有行。-1
选择上面一行。j
将这一行与下一行(即使用v
命令选择的行)连接起来Edit Benoit 和 dash-tom-bang 有在他们的注释中提供了实质性改进:
1
不是必需的,因为它是默认值,并且!
不会用空格连接行。因此,这导致了以下更好的版本:I believe you want to do a
The
v
command selects all lines that don't match the patterh/:/
. The-1
selects the lines one above. and thej
joins this line with the next line (i.e. the one selected with thev
command)Edit Benoit and dash-tom-bang have provided substantial improvements in their comments: the
1
is not necessary, since it is the default, and the!
does not join the lines with a space. So, this leads to the following, better version:模式
匹配没有
:
的行,当:v
命令不适合时(宏或脚本中的一些比较),它在更常见的任务中非常有用Pattern
matches lines without
:
, it can be useful in more common tasks when:v
command is not suitable (a macro or some comparison in script)