如何删除另一行的模式开头?
我想知道是否可以删除直到另一行的模式开始。
早上
- 好|
- 空行 空
- 行
- 空行
- ....
- 空行
- hello world
是否可以从光标“|”中删除在第 1 行直到“第 7 行的世界? (保持正常模式)
我经常这样做。通常我使用“dd”删除第1行和第7行之间的所有行,然后删除单词“dfw” 但如果我在第 347 行,而我的文本在第 381 行,这就很困难了。我必须计算它们之间的行数,而且经常删除一行太多。
I would like to know if it is possible to delete till the start of a pattern on another line.
p.e.
- good morning |
- empty line
- empty line
- empty line
- ....
- empty line
- hello world
Is it possible to delete from cursor "|" in line 1 till "world in line 7?
(remaining in normal mode)
I do this often. Normally I use "dd" to delete all lines between line 1 and line 7 and then delete to word "dfw"
but this is quit difficult if I'm on line 347 and my text is on 381. I have to count the lines between them and often I delete one line too much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用更通用的
d
命令,如下所示(^ 是您的光标),而不是使用dd
(删除单行),输入
d/the< /代码> 然后按 Enter 键。它将删除从光标到第一个搜索匹配的开头,留下
Rather than using
dd
(which deletes a single line), you can use the more generald
command as follows (^ is your cursor)Type
d/the
then press enter. It will delete from the cursor to the beginning of the first search match, leaving you with您可以搜索“世界”:
You can search for "world":