You can do the substitution on line 5 and repeat it with minimal effort on line 12:
:5s/foo/bar
:12&
As pointed out by Ingo, :&
forgets your flags. Since you are using /g
, the correct command would be :&&
:
:5s/foo/bar/g
:12&&
See :help :&
and friends.