Find and replace can be a godsend when you need to make the same text change multiple times. Let’s hope though that it isn’t multiple string/integer/etc. literal changes because that wouldn’t be very efficient coding – as in not DRY.

To do a global (within the current buffer) find and replace you issue the following:

:%s/the-text-to-replace/the-new-text/g
:%s/the-text-to-replace/the-new-text/g
  • : – issue VIM command
  • % – the buffer in the current window
  • s – substitute
  • g – replace every instance found

If you would like to find and replace within a selection, enter visual mode, make a selection and type:

:s/the-text-to-replace/the-new-text/g

And that’s it!