How to return to the previous one when you find a replacement confirmation in vi?

Often, when I do a search and replace in vi, I will do it as follows:

:%s/find/replace/gc

This gives you the ability to skip by clicking nor replace by clicking y. But sometimes I accidentally missed one in a large file by clicking nwhen I wanted to click y.

How can I go back to the previous one and give me a second change?

Essentially, how do I temporarily find( search) take another direction? thanks.

+8
source share
3 answers

I'm not sure if you want to interrupt the current replacement-replace operation and resume it again. But if that is acceptable, here is my suggestion:

  • - , : :%s/find/replace/gc
  • , , n, , <ctrl-C>
  • <shift-N>, find
  • find-replace -, : :.,$s/find/replace/gc

vim - .

. .,$ :s (substitute) , ( .), ( $).

2: , , , , - . % :s (substitute) .

+4

, . CtrlSF /.

, , .

:CtrlSF find, , /find n (, , .).

- , n, .

+2

, , . y/n/a/q/l/^E/^Y .

, :

  • /pattern ;
  • , , n ;
  • , , , cw, ;
  • ESC ;
  • n ;
  • , , . ;
  • , N
0

All Articles