Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Vim Modes

In this lab, you'll be working with Vim Modes. One of the most important things about editing in Vim is knowing what mode you are _in_, how to get _out_ of that mode and back to Command Mode, and then into the next mode you need to operate in. Being able to use the right mode to accomplish a needed step is critical, and this lab will ensure you know how to get to the right mode for the task.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 15m
Published
Clock icon Apr 03, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Start Vim, Lookup Vim Modes in Help, Practice Switching Modes

    1. Start the Vim editor:

      vim
      
    2. Use Help to lookup information about Vim modes:

      :help modes
      
    3. Notice this does not show help for the type of modes we are looking for, so try:

      :help vim-modes
      
    4. Note how many BASIC modes Vim has, and also the help part of the screen is not very large.

    5. To show more of the help screen, press the keystrokes:

      Note: This will not work while using the browser terminal.

      Ctrl-w    (Press and hold Ctrl, then w and release)
      10+       (Type 10 and then Shift-= or +)
      

      Note: This will increase the size of the Help window and allow you to read more without scrolling

    6. When done reading the descriptions of the seven Basic Modes, exit Help by pressing:

      :q
      
    7. Verify you are in Command Mode by pressing ESC twice in rapid succession. You should hear the Error Bell, or the screen should flash.

    8. Switch to Insert Mode by pressing the i character, and type a short sentence, such as This is a sentence in Vim. then press the ESC key to return to Command Mode.

      Note that when you are in Insert Mode, the bottom left of your Vim window has the mode shown as -- INSERT --.

    9. With your cursor on the line you have added, and use Visual Line mode to select the line by pressing:

      Shift-v
      
    10. Change the case of the text in the line with:

      Shift-u
      
    11. Use Command Line Mode to save your buffer to a file named file1.txt:

      ESC
      :w file1.txt
      
    12. Then exit Vim with:

      :q
      

      Note: If while trying to exit from Help, you are presented with a window that appears to contain commands, you pressed q:, so repeat the :q keystrokes until you have exited Help.

      Note: If at any time you are shown a message at the bottom left that Vim is recording @q, simply press the q key again to stop the recording.

  2. Challenge

    Use Help and Command Mode to Create a Working File, Use Visual Mode Select and Manipulate Text, and Use Command Mode to Save and Exit the File

    1. Open the Vim editor:
      vim
      
    2. Create a working file with:
      :help quotes
      :w ~/quotesdemo.txt
      
    3. When the file is written to disk (the status will read [converted]), quit Help with:
      :q
      
    4. While still in Vim, open the ~/quotesdemo.txt file in a buffer with:
      :e ~/quotesdemo.txt
      
    5. Navigate by your preferred means to the paragraph starting with:
      Coming with a very GUI mindset...
      
    6. Place your cursor on the first character of the word Coming and press v to start Visual mode. The last line should show -- VISUAL -- as a mode indicator.
    7. Then highlight/select the word Coming by pressing e to go to the end of that word.
    8. Press w twice to select two more words.
    9. Set the words to upper case by pressing U while they are selected.
    10. Enter Visual mode again by pressing:
      Shift-v
      
    11. Then move your cursor down to select the entire paragraph that starts with Coming and ends with Fonseca).
    12. Set the entire paragraph to upper case by pressing U while all the text is selected.
    13. Re-select the entire paragraph by pressing gv.
    14. Delete the paragraph by pressing d.
    15. Save and exit the file by pressing:
      ZZ
      

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans