How to search and replace in current line only?

Solution 1:

Replace all occurrences of str1 with str2 in certain line:

:s/str1/str2/g

remove the g option if you want to replace only the first occurrence.

Solution 2:

You can use . for the current line, like:

:.s/old/new/

This will change old by new in the current line only.