How to quickly find → replace OR skip in Vim

The aim of this page📝 is to use an improved “dot formula” to run a quick find & change OR skip → next in vim

Pavol Kutaj
Jul 23, 2024

It comes from Drew Neil, as described in his wonderful Practical Vim.

Looking for “SLOG”, replacing some with “LOG”, skipping some
  1. define exact match (ideally case sensitive with /C), but here just SLOG
  2. make operation (c/d/y/gU/…) → enters operator pending mode
  3. press gn to operate on the next match (for change — cgn)this combines action and moving to the next so that the repetition with the dot command is done with a single keystroke (.)

2+3 are pressed together in a typical operation+motion mode → you have just modified a match

Change-Next or Skip-Next?

  1. to skip press n
  2. to operate on the next press a single .

LINKS

http://vimcasts.org/episodes/operating-on-search-matches-using-gn/ https://vimhelp.org/visual.txt.html#gn

--

--

No responses yet