^search^replace
to replace first occurrence of string 'search' with 'replace' in previous command
!!:gs/search/replace/
to replace all 'search' with 'replace' in previous command
!<num>:gs/search/replace/
to replace all 'search' with 'replace' in command <num>
in history.
How can I replace the first occurrence of the 'search' in a particular command <num> in the command history?
You almost said the answer, because you already introduced all the elements needed:
!<num>:s/search/replace/
select the command you are interested on (!<num>
) followed by the transformation (:s/search/replace/
), but this time, ommiting the global designator (g
).