我将如何在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'
我将如何在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表示从包含“时间”的第一行开始的1行。
:help search-offset
您的语法几乎是正确的。您需要在模式之后使用第二个斜杠,以区分模式的末尾与接下来的内容。所以它看起来像这样: