DistributedNetworks DistributedNetworks


vi editing  «Prev  Next»

Searching Text in vi - Exercise

Searching for text in vi


Practicing forward and backward searches Objective: Use / and ? to search for text.

Exercise scoring

You will receive2 points for this exercise.

Submitting your exercise

This exercise is auto-scored. When you have finished, just click the Submit button to receive full credit.

Background/overview

In this exercise, you will practice using vi's search commands.

Instructions

  1. Log in to your course account.
  2. Change to the practice directory, and use the vi editor to open the phonelist file.
  3. Use the / command to search forward for the regular expression 2. (2 followed by any single character).
  4. Press n several times to repeat the search.
  5. Use the ? command to search backward for the regular expression 3[0-5] (3 followed by any digit 0 to 5).
  6. Press n several times to repeat the search in the same direction. Because you previously used the ? command, the search is repeated backward.
  7. Press N several times to repeat the search in the opposite direction, or forward, in this case.
  8. Quit vi, and log out when you are done.

Hints


Press Enter after the / or ? commands.