ex 编辑器高级使用指南:搜索、替换与多文件操作
1. 搜索模式
ex 编辑器可以通过搜索模式来定位行,以下是一些常见的搜索模式命令:
- :/pattern/d :删除下一个包含 pattern 的行。
- :/pattern/+d :删除下一个包含 pattern 的行的下一行(也可以用 +1 替代 + )。
- :/pattern1/,/pattern2/d :删除从第一个包含 pattern1 的行到第一个包含 pattern2 的行。
- :.,/pattern/m23 :将从当前行到第一个包含 pattern 的行的文本移动到第 23 行之后。
需要注意的是,模式前后都要用斜杠分隔。
在使用 vi 和 ex 按模式删除时,两个编辑器的操作方式有所不同。例如文件 practice 包含以下内容:
With a screen editor you can scroll the
page, move the cursor, delete lines, insert
characters and more, while seeing results
of your edits as you make them.
超级会员免费看
订阅专栏 解锁全文
6

被折叠的 条评论
为什么被折叠?



