Replacing Text in Vim

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

One feature of Vim is its ability to perform search-and-replace tasks with some complexity, using familiar sysadmin trappings such as `sed` and regular expressions. In this lab, you will put this into practice by making both mass and minimal changes to some provided code.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Update Dockerfile

Replace the appropriate instances of cloud_user with node at /home/cloud_user/app/Dockerfile.

Update server.js

Use Vim’s search-and-replace capabilities to update the appropriate text to all caps in the console log; ensure no other instances of app and port are changed.

Update todo.test.js

Replace only the appropriate instances of test to lowercase. (The parameter test that website works should not be changed.)

Additional Resources

You are performing some linting tasks of a simple application and need to make some mass changes to a number of files. Perform the following changes in Vim:

  • Update the Dockerfile to use the /home/node location and replace instances of cloud_user with node user.
  • Update server.js so that the instances of app and port in the console log are in all caps.
  • Update todo.test.js to ensure all instances of test are in lowercase. (The parameter test that website works should not be changed.)

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?