ex编辑器高级操作与全局替换指南
1. 搜索模式
ex编辑器可以使用搜索模式来定位行。以下是一些常见的搜索模式命令:
- :/pattern/d :删除下一个包含指定模式的行。
- :/pattern/+d :删除下一个包含指定模式的行的下一行(也可以使用 +1 代替 + )。
- :/pattern1/,/pattern2/d :删除从第一个包含 pattern1 的行到第一个包含 pattern2 的行。
- :.,/pattern/m23 :将当前行到第一个包含指定模式的行的文本移动到第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.
Keystrokes
Results
使用vi的 d/while 命令,会从
超级会员免费看
订阅专栏 解锁全文
9

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



