Pergunta

I would like to run a command such as :s/write/run/ on a line by line basis.

We can specify a range of lines such as :31,44s/write/run/.

We can also search :/write/ and press n to move to the next occurrence.

Is it possible to substitute in the same manner as search, by pressing a button and substituting the next occurrence?

Foi útil?

Solução

From the book Practical Vim:

:%s/content/copy/gc

The c flag causes Vim to show us each match and ask “Replace with copy?” We can then say y to perform the change or n to skip it. Vim does what we ask and then moves to the next match and asks us again.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top