6

I'm trying the following command in visual mode to attempt a global find/replace on a block of text

:'<,'>s/red/green/g

The text looks like this

red red red blue red red red blue

And the result

green red red blue red red red blue

Instead of what I am expecting with the g switch:

green green green blue green green green blue

Any idea what causes this behaviour? If it is default behaviour how do I make g really really global?

Thanks

darryn.ten
  • 6,784
  • 3
  • 47
  • 65

2 Answers2

8

You've probably :set gdefault; this inverts the meaning of the g substitution flag. You can check where it got set via :verbose set gdefault? and temporarily turn it off via :set nogdefault, but you probably want to find the place where it got set and remove it from there.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
0

I tried this in my vim and get the correct result as:

green green green blue green green green blue

Maybe there is something in your .vimrc changing the default behavior. Would you like to attach it to this thread?

imapollo
  • 387
  • 1
  • 2
  • 16