To perform a buffer-wide substitution on all occurrences of foo (and not just the 1st one in a line), we can do


The g flag may be omitted by setting this in the vimrc as

set gdefault

If the pattern foo is not found, vim raises an error

E486: Pattern not found: foo

This error can be avoided by specifying the e flag to the substitution operator i.e.


My question is, can an equivalent option (say edefault) that can be put together in a vimrc to achieve this effect?

  • 3
    No, there is not and btw: I would not recommend setting gdefault. It is to obscure and I suspect too many plugins cannot handle it Jun 20, 2019 at 12:52
  • @ChristianBrabandt Ok, I agree with your views on gdefault. What about edefault. Can something be cooked up? Jun 20, 2019 at 19:05
  • I am not sure what you mean with cooked up. In interactive mode, a missing edefault does not make sense since the error message is quite helpful. Scripts/plugins however can use various ways to compensate, using either try/catch or always including the e flag. So what exact problem are you trying to solve here? Jun 21, 2019 at 6:32


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.