What's the vim way to select multiple instances of current word and change them?

前端 未结 3 1519
無奈伤痛
無奈伤痛 2021-02-01 22:20

Anyone familiar with Sublime Text\'s multiple cursor feature will recognize the pattern of doing the following: press a hotkey multiple times to select multiple instances of the

3条回答
  •  不思量自难忘°
    2021-02-01 22:57

    I use the *, gn, and the . to make changes.

    • Select current word with * (go back with N)
    • Change word with gn motion. e.g. cgnfoo
    • Repeat via . command

    Note: If you have many changes then using a substitution command would probably be better.

    There is a nice Vimcasts episode about the gn motion: Operating on search matches using gn.

    For more help see:

    :h *
    :h gn
    :h .
    

提交回复
热议问题