0

Let's say I want to change All occurrences of 'foo' to 'bar' on a line. I'd do this with

:s/foo/bar/g

For some reason it only substitutes the first occurrence of 'foo'. Why could be causing this?

sjbuysse
  • 3,872
  • 7
  • 25
  • 37
  • `g` means global. So, it should substitute all occurrences in the line. Start vim like `vim -u None filename` and then substitute, it will work. In that case, you have some issue or setting set off. – SibiCoder May 27 '16 at 03:46
  • 4
    http://stackoverflow.com/questions/11812615/what-causes-substitution-in-vim-to-only-match-one-element-per-line/11812628#11812628 – FDinoff May 27 '16 at 04:14
  • Beautiful! Thanks @FDinoff, I somehow missed that topic. – sjbuysse May 27 '16 at 06:36

0 Answers0