I searched a little for a global function that would act as the :g command but in a more Function-style.

Like the substitute command which has a function associated :

:h substitute()
:h :substitute

Do you know if such exists ?

  • substitute() acts on a string - are you looking for a global() function that acts on a string? If not, you are not looking for a :g equivalent in the same way substitute() is associated with :substitute.
    – VanLaser
    Commented Sep 2, 2015 at 18:30
  • I don't know exactly what you're looking for, but :help function-list will show you all the built-in functions with short descriptions and should help you find something that meets your needs. Also, it's common in scripts to put a while loop around a call to search() and then perform the desired editing operation (e.g., substitute()) on the lines found.
    – garyjohn
    Commented Sep 2, 2015 at 18:31
  • @VanLaser : yes exactly
    – nobe4
    Commented Sep 2, 2015 at 20:17
  • @garyjohn : I know, that is where I searched for it
    – nobe4
    Commented Sep 2, 2015 at 20:18

1 Answer 1


No there is no such function and it would not make much sense. If you need to do something for each item in a list, you can loop around it.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.