基于搜索的Vim测线范围
我如何在vim中执行以下操作基于搜索的Vim测线范围,vim,Vim,我如何在vim中执行以下操作 :1,/time s/import/new/g 我想做的是: - `:1,` from line 1... - `/time` until the (first) match of the word 'time' - `s/import/new/g` substitute the word 'import' with the word 'new' 您的语法几乎正确。您需要在模式后使用第二条斜线来区分模式的结尾和接下来的内容。所以看起来是这样的: :1,/time
:1,/time s/import/new/g
我想做的是:
- `:1,` from line 1...
- `/time` until the (first) match of the word 'time'
- `s/import/new/g` substitute the word 'import' with the word 'new'
您的语法几乎正确。您需要在模式后使用第二条斜线来区分模式的结尾和接下来的内容。所以看起来是这样的:
:1,/time/ s/import/new/g
您的语法几乎正确。您需要在模式后使用第二条斜线来区分模式的结尾和接下来的内容。所以看起来是这样的:
:1,/time/ s/import/new/g
您希望使用搜索偏移功能。 此命令排除包含“时间”的行
1,/time/-1s/import/new/g
这里的-1表示从包含“time”的第一行开始的1行
:help search offset要使用搜索偏移功能。 此命令排除包含“时间”的行
1,/time/-1s/import/new/g
这里的-1表示从包含“time”的第一行开始的1行
:help search offset我明白了,谢谢你关于它与+1或-1互斥/包含的提示。我明白了,谢谢你关于它与+1或-1互斥/包含的提示。