Probably one of the most useful piece of knowledge this year I got from a colleague who showed me the use of the following:

$ echo hi
$ ^hi^hello
echo hello

This quick substitution saved me work already on countless occasions when mistakes have been made and the same command needed to be re-run again.

As usual, the bash man-page mention this functionality.

histchars The two or three characters which control history expansion and tokenization (see HISTORY EXPANSION below). The first character is the history expansion character, the character which signals the start of a history expansion, normally !'. The second character is the quick substitution character, which is used as shorthand for re-running the previous command entered, substituting one string for another in the command. The default is ^’. […]

And another time in more details:

^string1^string2^ Quick substitution. Repeat the previous command, replacing string1 with string2. Equivalent to ``!!:s/string1/string2/’’ (see Modifiers below).

Quickly I also hit its limitation:

$ echo ha ha ha
ha ha ha
$ ^ha^ho
echo ho ha ha
ho ha ha

It only replaces the first match. Considering the comment in the man page, this is quite obvious:

Equivalent to ``!!:s/string1/string2/’’

So the obvious fix is a tiny bit more complex:

$ echo ha ha ha
ha ha ha
$ ^ha^ho^:g&
echo ho ho ho
ho ho ho

There you go….