Multiple choice technology platforms and products

Which of the following will work with substitue command ?

  1. :%s/old/new/g

  2. :$s/old/new
  3. :&s/old/new

  4. :.+10s/old/new

Reveal answer Fill a bubble to check yourself
A,B,D Correct answer
Explanation

The vi substitute command works with ranges including: % (entire file), $ (current line), and +10 (10 lines below current). However, & does NOT work with the substitute command - & is used to repeat the previous substitution, not as a range specifier. Options A, B, and D are all valid range specifiers for the substitute command.