-1

When I do something like :%s/orig/new in macvim, not :%s/orig/new/g, it still replaces all occurences of orig throughout the file. I only want it to replace all the occurences in the current line.

Is this normal for macvim? Might this be an option I've accidently set in .vimrc? How to fix it?

Mattias
  • 615
  • 1
  • 5
  • 17

1 Answers1

3

:%s replaces in the entire file because % is the "all-file" range. To replace only in the current line do not use any addresses at all:

:s/old/new/g

Flag g means "replace all occurrences in the line", not in the entire file.

phd
  • 57,284
  • 10
  • 68
  • 103