Multiple choice technology

Command to replace a word with another word?

  1. :s/<old_word>/<new_word>/

  2. :%s/<old_word>/<new_word>/

  3. :%s/<old_word>/<new_word>/g

  4. :s/<old_word>/<new_word>/g

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

:%s/old/new/g searches for ALL occurrences in the ENTIRE file ('%' means all lines, 'g' means all occurrences per line). :s/old/new only affects first occurrence on current line. :s/old/new/g affects all occurrences on current line only. :%s/old/new affects first occurrence on all lines.