Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Introduction to Linux Level One Β· Lesson 6 of 9

Module FIve

πŸ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
6
Module Four: The vi Text Editor

πŸ“ Module Four: The vi Text Editor


πŸ“– Module Introduction

Welcome to Module Four of your Introduction to Linux Level One course! In this module, we will learn about the vi Text Editor.

Imagine you are a writer. You need a notebook and a pen to write down your ideas. In Linux, the vi editor is like that notebook and pen. It is a tool that lets you create and edit text files right inside the terminal.

vi is one of the most powerful text editors in Linux. It is used by programmers, system administrators, and many other professionals. It might seem a little strange at first because it works differently from the editors you might be used to, but once you learn it, you will be able to edit files very quickly.

In this module, you will learn how to open vi, how to type text, how to save your work, and how to quit vi. You will also learn some basic navigation and editing commands.

By the end of this module, you will be comfortable using vi to create and edit text files. Let's begin our vi adventure!


🎯 Learning Objectives

By the time you finish this module, you will be able to:

  • Explain what vi is and why it is used.
  • Open vi and create a new file.
  • Understand the two main modes of vi: command mode and insert mode.
  • Switch between command mode and insert mode.
  • Type and edit text in vi.
  • Save your work and quit vi.
  • Use basic navigation commands in vi.
  • Use basic editing commands in vi.
  • Understand how to undo changes.
  • Feel confident using vi for basic editing.

πŸ“š Warm-up Story: The Magic Typewriter

Once upon a time, there was a magic typewriter that could only be used in a special way. It had two modes: command mode and writing mode.

In writing mode, you could type words freely, just like a normal typewriter. But to do anything elseβ€”like move to a new line, save your work, or fix a mistakeβ€” you had to switch to command mode.

At first, people were confused. They kept trying to type, but the typewriter wouldn't respond. They had to learn the special keys that let them switch between modes. Once they learned, they realized the typewriter was incredibly powerful. They could write faster and fix mistakes more easily than with any other typewriter.

The vi editor is exactly like that magic typewriter. It has command mode and insert mode. In insert mode, you type text. In command mode, you give commands to the editor. Once you learn how to switch between them, you can edit files very quickly and efficiently.

Let's learn how to use this magic editor!


πŸ“Œ Lesson 1: What is vi?

Definition: vi is a text editor that runs in the terminal. It is used to create and edit text files.

Why it is important: vi is available on almost every Linux system. It is a powerful tool that many professionals use.

Simple explanation: vi is like a notebook for your computer. You can write anything you want in it.

Real-life example: Programmers use vi to write code. System administrators use vi to edit configuration files.

School example: A student uses vi to write an essay.

Home example: A person uses vi to write a shopping list.

Nigerian example: Nigerian developers use vi to write code.

Illustration:

    vi EDITOR
         |
         +--- Text editor
         |
         +--- Runs in the terminal
         |
         +--- Powerful and fast
         |
         +--- Used by professionals
         |
         V
    CREATE AND EDIT FILES
    

Mini summary: vi is a powerful text editor that runs in the terminal. It is used to create and edit text files.


πŸ“Œ Lesson 2: Opening vi

Definition: You open vi by typing vi followed by the name of the file you want to edit.

Why it is important: You need to know how to open vi before you can use it.

Simple explanation: Opening vi is like opening a notebook to start writing.

Real-life example: Type vi notes.txt to open a file called "notes.txt".

School example: A student types vi essay.txt to open a file for their essay.

Home example: You type vi shopping.txt to open a file for your shopping list.

Nigerian example: A developer types vi index.html to open a web page file.

Illustration:

    OPENING vi
    user@computer:~$ vi filename.txt
    (This opens filename.txt in vi)
    

Mini summary: You open vi by typing "vi" followed by the file name.


πŸ“Œ Lesson 3: The Two Modes of vi

Definition: vi has two main modes: command mode and insert mode.

Why it is important: You need to understand the modes to use vi effectively. In insert mode, you type text. In command mode, you give commands.

Simple explanation: The two modes are like two sides of a magic pen. One side writes, and the other side erases and edits.

Real-life example: In command mode, you can move around, delete text, and save the file. In insert mode, you can type new text.

School example: A student uses insert mode to type their essay and command mode to fix mistakes.

Home example: You use insert mode to write your shopping list and command mode to delete an item.

Nigerian example: A developer uses command mode to navigate code and insert mode to write new code.

Illustration:

    vi MODES
    +-------------------+-------------------+
    | Command Mode      | Insert Mode       |
    +-------------------+-------------------+
    | Move around       | Type text         |
    | Delete text       | Add new text      |
    | Save and quit     |                   |
    +-------------------+-------------------+
    

Mini summary: vi has two modes: command mode and insert mode. You type in insert mode and give commands in command mode.


πŸ“Œ Lesson 4: Insert Mode

Definition: Insert mode is the mode where you can type text.

Why it is important: You need to be in insert mode to add new text to a file.

Simple explanation: Insert mode is like writing with a pen. Whatever you type appears on the screen.

Real-life example: Press i to enter insert mode. Now you can type.

School example: A student presses "i" to start typing their essay.

Home example: You press "i" to start typing your shopping list.

Nigerian example: A developer presses "i" to start writing code.

Illustration:

    ENTERING INSERT MODE
    Press 'i' to enter insert mode
    -- INSERT --
    Now you can type your text
    

Mini summary: Insert mode is where you type text. Press "i" to enter insert mode.


πŸ“Œ Lesson 5: Command Mode

Definition: Command mode is the mode where you give commands to the vi editor.

Why it is important: You need to be in command mode to save, quit, delete, and navigate.

Simple explanation: Command mode is like giving instructions to the editor. You tell it what to do.

Real-life example: Press Esc to return to command mode from insert mode.

School example: A student presses "Esc" to stop typing and give a command.

Home example: You press "Esc" to stop typing and save your file.

Nigerian example: A developer presses "Esc" to navigate code.

Illustration:

    COMMAND MODE
    Press 'Esc' to enter command mode
    (Now you can give commands)
    :w  (save)
    :q  (quit)
    dd  (delete line)
    

Mini summary: Command mode is where you give commands. Press "Esc" to enter command mode.


πŸ“Œ Lesson 6: Switching Between Modes

Definition: You switch between modes using keys. Press "i" to go to insert mode. Press "Esc" to go to command mode.

Why it is important: You need to switch between modes to type and give commands.

Simple explanation: Switching modes is like changing tools. You use one tool to write and another to edit.

Real-life example: Press "i" to type. Press "Esc" to stop typing and give commands.

School example: A student switches between modes to type and edit their essay.

Home example: You switch between modes to write and save your shopping list.

Nigerian example: A developer switches between modes to write and navigate code.

Illustration:

    SWITCHING MODES
    Command Mode  -------- i -------->  Insert Mode
    Insert Mode   -------- Esc ------>  Command Mode
    

Mini summary: Press "i" to go to insert mode. Press "Esc" to go to command mode.


πŸ“Œ Lesson 7: Saving and Quitting

Definition: To save and quit vi, you use commands in command mode.

Why it is important: You need to save your work before you close the file.

Simple explanation: Saving is like putting your notebook away after writing.

Real-life example: :w saves the file. :q quits vi. :wq saves and quits. :q! quits without saving.

School example: A student types ":wq" to save and quit their essay.

Home example: You type ":wq" to save and quit your shopping list.

Nigerian example: A developer types ":wq" to save and quit their code.

Illustration:

    SAVING AND QUITTING
    :w    (save)
    :q    (quit)
    :wq   (save and quit)
    :q!   (quit without saving)
    

Mini summary: Use ":w" to save, ":q" to quit, ":wq" to save and quit, and ":q!" to quit without saving.


πŸ“Œ Lesson 8: Navigating in Command Mode

Definition: In command mode, you can move around the file using keys like h, j, k, l.

Why it is important: You need to move to different parts of the file to edit them.

Simple explanation: Navigation keys are like arrows that move the cursor around the page.

Real-life example: h moves left, j moves down, k moves up, l moves right.

School example: A student uses these keys to move around their essay.

Home example: You use these keys to move around your shopping list.

Nigerian example: A developer uses these keys to navigate code.

Illustration:

    NAVIGATION KEYS
    +-------------------+-------------------+
    | Key               | Action            |
    +-------------------+-------------------+
    | h                 | Move left         |
    | j                 | Move down         |
    | k                 | Move up           |
    | l                 | Move right        |
    | 0 (zero)          | Move to start of  |
    |                   | line              |
    | $                 | Move to end of    |
    |                   | line              |
    | G                 | Go to end of file |
    +-------------------+-------------------+
    

Mini summary: Use h, j, k, l to move around in command mode.


πŸ“Œ Lesson 9: Basic Editing Commands

Definition: In command mode, you can delete, copy, and paste text using simple commands.

Why it is important: You need these commands to edit your text quickly.

Simple explanation: Editing commands are like erasers and scissors for your text.

Real-life example: x deletes the character under the cursor. dd deletes the entire line. dw deletes a word.

School example: A student uses "dd" to delete a line in their essay.

Home example: You use "x" to delete a character in your shopping list.

Nigerian example: A developer uses "dw" to delete a word in code.

Illustration:

    EDITING COMMANDS
    +-------------------+-------------------+
    | Command           | Action            |
    +-------------------+-------------------+
    | x                 | Delete character  |
    | dd                | Delete line       |
    | dw                | Delete word       |
    | u                 | Undo              |
    | yy                | Copy line (yank)  |
    | p                 | Paste             |
    +-------------------+-------------------+
    

Mini summary: Use commands like x, dd, dw, u, yy, and p to edit text.


πŸ“Œ Lesson 10: Undo and Redo

Definition: u undoes the last change. Ctrl + r redoes a change.

Why it is important: Mistakes happen. Undo lets you fix them easily.

Simple explanation: Undo is like taking back a mistake. Redo is like putting it back.

Real-life example: Press u to undo a deletion. Press Ctrl + r to redo.

School example: A student uses "u" to undo a mistake in their essay.

Home example: You use "u" to undo a deletion in your shopping list.

Nigerian example: A developer uses "u" to undo a change in code.

Illustration:

    UNDO AND REDO
    u          (undo)
    Ctrl + r   (redo)
    

Mini summary: Use "u" to undo changes and "Ctrl + r" to redo them.


πŸ“Œ Lesson 11: Copying and Pasting

Definition: yy copies (yanks) a line. p pastes the copied text.

Why it is important: Copying and pasting saves time when you need to repeat text.

Simple explanation: Copying and pasting is like using a photocopier for your text.

Real-life example: Press yy to copy a line. Move the cursor and press p to paste it.

School example: A student copies a line in their essay.

Home example: You copy a line in your shopping list.

Nigerian example: A developer copies a line of code.

Illustration:

    COPY AND PASTE
    yy     (copy line)
    p      (paste below cursor)
    P      (paste above cursor)
    

Mini summary: Use "yy" to copy a line and "p" to paste it.


πŸ“Œ Lesson 12: Searching in vi

Definition: You can search for text in vi using the / command.

Why it is important: Searching helps you find specific words quickly in a large file.

Simple explanation: Searching is like using a magnifying glass to find something in a book.

Real-life example: Type /word to search for "word". Press n to go to the next match.

School example: A student searches for a specific word in their essay.

Home example: You search for an item in your shopping list.

Nigerian example: A developer searches for a variable name in code.

Illustration:

    SEARCHING
    /word    (search for "word")
    n        (next match)
    N        (previous match)
    

Mini summary: Use "/" to search for text and "n" to find the next match.


πŸ“Œ Lesson 13: Replacing Text

Definition: You can replace text using the :s command.

Why it is important: Replacing helps you change words quickly without typing them again.

Simple explanation: Replacing is like using whiteout to change a word.

Real-life example: :s/old/new/g replaces all "old" with "new" in the current line.

School example: A student replaces a word in their essay.

Home example: You replace an item in your shopping list.

Nigerian example: A developer replaces a variable name in code.

Illustration:

    REPLACING TEXT
    :s/old/new/     (replace first "old" in line)
    :s/old/new/g    (replace all "old" in line)
    :%s/old/new/g   (replace all "old" in file)
    

Mini summary: Use ":s/old/new/" to replace text in vi.


πŸ“Œ Lesson 14: vi Tips and Tricks

Definition: Here are some tips and tricks to help you use vi more effectively.

Why it is important: These tips will make you faster and more efficient in vi.

Simple explanation: Tips are like shortcuts that make your work easier.

Real-life example: G goes to the end of the file. gg goes to the beginning. Ctrl + f moves forward one page. Ctrl + b moves backward one page.

School example: A student uses "G" to go to the end of their essay.

Home example: You use "gg" to go to the beginning of your shopping list.

Nigerian example: A developer uses "Ctrl + f" to scroll through code.

Illustration:

    vi TIPS
    G          (go to end of file)
    gg         (go to beginning of file)
    Ctrl + f   (move forward one page)
    Ctrl + b   (move backward one page)
    .          (repeat last command)
    

Mini summary: Use G, gg, Ctrl + f, Ctrl + b, and . to work faster in vi.


πŸ“Œ Lesson 15: You Can Use vi!

Definition: Learning vi is a valuable skill that will help you in many Linux tasks.

Why it is important: vi is available on every Linux system. Knowing vi makes you a more capable Linux user.

Simple explanation: Learning vi is like learning to ride a bicycle. It might feel strange at first, but once you learn, you never forget.

Real-life example: Many professionals use vi every day.

School example: A student can use vi to edit files for school projects.

Home example: You can use vi to edit any text file.

Nigerian example: Nigerian developers use vi for coding and editing.

Illustration:

    LEARNING vi
         |
         +--- Practice regularly
         |
         +--- Learn the commands
         |
         +--- Use it every day
         |
         +--- Become an expert
         |
         V
    MASTER THE EDITOR
    

Mini summary: Anyone can learn vi with practice. It is a valuable skill for Linux users.


πŸ“– Key Vocabulary

Word Simple Definition
vi A powerful text editor for Linux.
Command Mode The mode where you give commands.
Insert Mode The mode where you type text.
Navigate To move around in a file.
Delete To remove text.
Undo To reverse a change.
Redo To reapply a change that was undone.
Yank To copy text in vi.
Paste To insert copied text.
Search To find text in a file.

🧠 Important Concepts

  • vi is a powerful text editor: It is used by many professionals.
  • There are two modes: Command mode and insert mode.
  • You type in insert mode: Press "i" to enter insert mode.
  • You give commands in command mode: Press "Esc" to enter command mode.
  • Save with ":w": This saves your file.
  • Quit with ":q": This closes vi.
  • Use navigation keys: h, j, k, l to move around.
  • Use editing commands: x, dd, dw, u, yy, p.
  • Search with "/": Find text quickly.
  • Practice makes perfect: The more you use vi, the better you become.

πŸ“ Step-by-Step Explanations

How to create and edit a file in vi:

  1. Open vi: Type "vi filename.txt" in the terminal.
  2. Enter insert mode: Press the "i" key.
  3. Type your text: Write whatever you want in the file.
  4. Return to command mode: Press the "Esc" key.
  5. Save the file: Type ":w" and press Enter.
  6. Quit vi: Type ":q" and press Enter.
  7. Save and quit: Type ":wq" and press Enter.

How to delete text in vi:

  1. Make sure you are in command mode: Press "Esc".
  2. Move to the text you want to delete: Use h, j, k, l.
  3. Delete a character: Press "x".
  4. Delete a line: Press "dd".
  5. Delete a word: Press "dw".
  6. Undo if you make a mistake: Press "u".

🌍 Real-Life Examples

  • Programmers: Use vi to write and edit code.
  • System Administrators: Use vi to edit configuration files.
  • Writers: Use vi to write articles and books.
  • DevOps Engineers: Use vi to edit deployment scripts.
  • Students: Use vi to take notes and write essays.

πŸ‡³πŸ‡¬ Nigerian Examples

  • Andela: Developers use vi for coding.
  • Flutterwave: Engineers use vi to edit configuration files.
  • Paystack: Developers use vi for code editing.
  • Universities: Students learn vi in computer science courses.
  • Government agencies: IT staff use vi to edit system files.

🧸 Fun Examples

  • Writing a story: Use vi to write a story.
  • Making a list: Use vi to make a to-do list.
  • Taking notes: Use vi to take notes in class.
  • Writing a letter: Use vi to write a letter to a friend.
  • Creating a journal: Use vi to keep a daily journal.

🏠 Everyday Examples

  • Shopping list: Use vi to make a shopping list.
  • To-do list: Use vi to make a to-do list.
  • Notes: Use vi to take notes.
  • Recipe: Use vi to write a recipe.
  • Diary: Use vi to write a diary entry.

πŸ‘©β€πŸ« Teacher Notes

  • Use the warm-up story to introduce vi.
  • Encourage students to practice vi commands.
  • Use hands-on activities where students create and edit files.
  • Emphasize the importance of the two modes.
  • Use examples from Nigerian culture to make it relatable.

πŸ‘¨β€πŸ‘©β€πŸ‘¦ Parent Tips

  • Encourage your child to practice vi at home.
  • Help your child create and edit text files.
  • Discuss the importance of text editors in technology.
  • Support your child's learning journey.
  • Celebrate your child's progress.

πŸ€” Interesting Facts

  • vi was created in 1976 by Bill Joy.
  • vi is short for "visual editor".
  • vi is available on almost every Unix and Linux system.
  • Many people consider vi to be the most powerful text editor.
  • vi is often used by programmers and system administrators.

πŸ’‘ Did You Know?

  • Did you know that vi was created by Bill Joy in 1976?
  • Did you know that vi is pronounced "vee-eye"?
  • Did you know that vi is available on almost every Linux system?
  • Did you know that vi has many advanced features for programmers?
  • Did you know that learning vi can make you a faster editor?

🧾 Remember This

  • vi is a powerful text editor.
  • vi has two modes: command mode and insert mode.
  • Press "i" to enter insert mode.
  • Press "Esc" to enter command mode.
  • Use ":w" to save, ":q" to quit, ":wq" to save and quit.
  • Use h, j, k, l to navigate.
  • Use x, dd, dw, u, yy, p to edit.
  • Use "/" to search.
  • Practice regularly to become comfortable with vi.
  • vi is a valuable skill for Linux users.

⚠️ Common Mistakes

  • Not knowing which mode you are in: Check the bottom of the screen for "-- INSERT --" or not.
  • Pressing "i" multiple times: This just re-enters insert mode.
  • Forgetting to save: Losing your work because you didn't save.
  • Using the wrong commands: Confusing "w" with "q".
  • Not using "Esc": Trying to type commands in insert mode.
  • Giving up too soon: vi takes practice to master.

⭐ Best Practices

  • Learn the basic commands first: Start with the essentials.
  • Practice regularly: Use vi for everyday editing.
  • Know your modes: Always be aware of which mode you are in.
  • Save often: Use ":w" frequently to avoid losing work.
  • Use undo: Press "u" if you make a mistake.
  • Read the help: Use ":help" to learn more.
  • Don't give up: vi takes time to learn, but it's worth it.

🎨 Clear Illustrations

vi Modes

    +-------------------+-------------------+
    | Command Mode      | Insert Mode       |
    +-------------------+-------------------+
    | Move around       | Type text         |
    | Delete text       | Add new text      |
    | Save and quit     |                   |
    +-------------------+-------------------+
    

Switching Modes

    Command Mode  -------- i -------->  Insert Mode
    Insert Mode   -------- Esc ------>  Command Mode
    

Navigation Keys

    +-------------------+-------------------+
    | Key               | Action            |
    +-------------------+-------------------+
    | h                 | Move left         |
    | j                 | Move down         |
    | k                 | Move up           |
    | l                 | Move right        |
    | 0 (zero)          | Move to start of  |
    |                   | line              |
    | $                 | Move to end of    |
    |                   | line              |
    | G                 | Go to end of file |
    +-------------------+-------------------+
    

Basic Commands

    +-------------------+-------------------+
    | Command           | Action            |
    +-------------------+-------------------+
    | i                 | Enter insert mode |
    | Esc               | Enter command mode|
    | :w                | Save              |
    | :q                | Quit              |
    | :wq               | Save and quit     |
    | :q!               | Quit without save |
    | x                 | Delete character  |
    | dd                | Delete line       |
    | dw                | Delete word       |
    | u                 | Undo              |
    | yy                | Copy line         |
    | p                 | Paste             |
    | /word             | Search            |
    +-------------------+-------------------+
    

Searching Example

    user@computer:~$ vi notes.txt
    (Open file)
    /searchword
    (Search for "searchword")
    n  (next match)
    N  (previous match)
    

πŸ“Š Comparison Tables

vi vs. Other Text Editors

vi nano gedit
Terminal-based Terminal-based Graphical
Very powerful Simple User-friendly
Steep learning curve Easy to learn Very easy
Available everywhere Available everywhere Not always available
Used by professionals Used by beginners Used by beginners

Command Mode vs. Insert Mode

Command Mode Insert Mode
Give commands Type text
Navigate Add new text
Delete Edit text
Save/Quit
Press "Esc" to enter Press "i" to enter

Lesson 1 Summary

vi is a powerful text editor that runs in the terminal.

Lesson 2 Summary

You open vi by typing "vi" followed by the file name.

Lesson 3 Summary

vi has two modes: command mode and insert mode.

Lesson 4 Summary

Insert mode is where you type text. Press "i" to enter.

Lesson 5 Summary

Command mode is where you give commands. Press "Esc" to enter.

Lesson 6 Summary

Press "i" to go to insert mode. Press "Esc" to go to command mode.

Lesson 7 Summary

Use ":w" to save, ":q" to quit, ":wq" to save and quit.

Lesson 8 Summary

Use h, j, k, l to navigate in command mode.

Lesson 9 Summary

Use x, dd, dw, u, yy, p to edit text.

Lesson 10 Summary

Use "u" to undo and "Ctrl + r" to redo.

Lesson 11 Summary

Use "yy" to copy a line and "p" to paste it.

Lesson 12 Summary

Use "/" to search for text and "n" to find the next match.

Lesson 13 Summary

Use ":s/old/new/" to replace text.

Lesson 14 Summary

Use G, gg, Ctrl + f, Ctrl + b, and . to work faster in vi.

Lesson 15 Summary

Anyone can learn vi with practice. It is a valuable skill.


πŸ“ End-of-Module Summary

Congratulations! You have completed Module Four: The vi Text Editor!

You have learned what the vi text editor is and why it is used. You now understand the two modes: command mode and insert mode. You learned how to open vi, type text, save your work, and quit the editor.

You also learned how to navigate in vi, use basic editing commands, undo and redo changes, copy and paste text, search for text, and replace text. You also learned some tips and tricks to work faster in vi.

Remember, vi is a powerful tool that is used by many professionals. The more you practice, the more comfortable you will become. Don't be afraid to make mistakesβ€”that's how you learn!

In the next module, Module Five: User and Group Management, you will learn how to manage users and groups on a Linux system.


❓ Frequently Asked Questions

  1. Q: What is vi?
    A: vi is a powerful text editor for Linux.
  2. Q: What are the two modes of vi?
    A: The two modes are command mode and insert mode.
  3. Q: How do I enter insert mode?
    A: Press "i" to enter insert mode.
  4. Q: How do I enter command mode?
    A: Press "Esc" to enter command mode.
  5. Q: How do I save a file in vi?
    A: Type ":w" and press Enter.
  6. Q: How do I quit vi?
    A: Type ":q" and press Enter.
  7. Q: How do I save and quit vi?
    A: Type ":wq" and press Enter.
  8. Q: How do I quit vi without saving?
    A: Type ":q!" and press Enter.
  9. Q: How do I delete a line in vi?
    A: Press "dd" in command mode.
  10. Q: Is vi hard to learn?
    A: vi takes practice, but it is a valuable skill.

πŸ“ Review Questions

  1. What is vi?
  2. What are the two modes of vi?
  3. How do you enter insert mode?
  4. How do you enter command mode?
  5. How do you save a file in vi?
  6. How do you quit vi?
  7. How do you save and quit vi?
  8. How do you quit vi without saving?
  9. What key is used to navigate down in vi?
  10. What key is used to delete a character?
  11. What key is used to delete a line?
  12. How do you undo a change?
  13. How do you copy a line?
  14. How do you paste copied text?
  15. How do you search for text?

✏️ Fill-in-the-Blank Exercises

  1. vi is a powerful __________ editor.
  2. The two modes of vi are __________ mode and insert mode.
  3. Press __________ to enter insert mode.
  4. Press __________ to enter command mode.
  5. Type __________ to save a file.
  6. Type __________ to quit vi.
  7. Type __________ to save and quit vi.
  8. Press __________ to delete a line.
  9. Press __________ to undo a change.
  10. Press __________ to search for text.

βœ… True or False Exercises

  1. vi is a text editor. (True)
  2. vi has only one mode. (False)
  3. Press "i" to enter command mode. (False)
  4. Press "Esc" to enter command mode. (True)
  5. ":w" saves the file. (True)
  6. ":q" quits vi without saving. (False)
  7. ":wq" saves and quits. (True)
  8. "dd" deletes a word. (False)
  9. "u" undoes a change. (True)
  10. vi is a valuable skill for Linux users. (True)

πŸ”˜ Multiple Choice Questions

  1. What is vi?
    A) A web browser
    B) A text editor
    C) A game
    Answer: B
  2. What are the two modes of vi?
    A) Read and Write
    B) Command and Insert
    C) Edit and Save
    Answer: B
  3. How do you enter insert mode?
    A) Press "Esc"
    B) Press "i"
    C) Press ":"
    Answer: B
  4. How do you enter command mode?
    A) Press "Esc"
    B) Press "i"
    C) Press ":"
    Answer: A
  5. How do you save a file in vi?
    A) :w
    B) :q
    C) :wq
    Answer: A
  6. How do you quit vi?
    A) :w
    B) :q
    C) :wq
    Answer: B
  7. How do you save and quit vi?
    A) :w
    B) :q
    C) :wq
    Answer: C
  8. How do you quit vi without saving?
    A) :w
    B) :q!
    C) :wq
    Answer: B
  9. What key moves the cursor down?
    A) h
    B) j
    C) k
    Answer: B
  10. What key deletes a character?
    A) x
    B) dd
    C) dw
    Answer: A
  11. What key deletes a line?
    A) x
    B) dd
    C) dw
    Answer: B
  12. How do you undo a change?
    A) u
    B) Ctrl + r
    C) yy
    Answer: A
  13. How do you copy a line?
    A) yy
    B) yw
    C) y$
    Answer: A
  14. How do you paste text?
    A) p
    B) y
    C) d
    Answer: A
  15. How do you search for text?
    A) /word
    B) :/word
    C) ?word
    Answer: A

πŸ”— Matching Exercises

Match the command to its action:

Command Action
1. i A) Save
2. Esc B) Quit
3. :w C) Enter insert mode
4. :q D) Enter command mode
5. :wq E) Delete line
6. dd F) Save and quit
7. u G) Copy line
8. yy H) Undo

Answers: 1-C, 2-D, 3-A, 4-B, 5-F, 6-E, 7-H, 8-G


πŸ“ Short Answer Questions

  1. What is vi in your own words?
  2. What is the difference between command mode and insert mode?
  3. How do you save a file in vi?
  4. How do you undo a change in vi?
  5. Why is vi a valuable skill for Linux users?

🎭 Scenario-Based Exercises

Scenario 1: You need to create a new file called "notes.txt" and write a few sentences. What commands would you use?

Scenario 2: You made a mistake while typing and want to undo it. What command would you use?

Scenario 3: You want to delete a line in your file. What command would you use?

Scenario 4: You want to copy a line and paste it somewhere else. What commands would you use?


πŸ‘₯ Group Activity

Activity: Create a vi Cheat Sheet.

Instructions:

  1. In groups of 4-5, create a cheat sheet of the most useful vi commands.
  2. Include: how to open, save, quit, navigate, edit, and search.
  3. Add examples and simple language.
  4. Present your cheat sheet to the class.

πŸ§‘β€πŸŽ“ Individual Activity

Activity: Practice vi Editing.

Instructions:

  1. Open vi and create a file called "practice.txt".
  2. Type a few sentences.
  3. Practice navigating, deleting, and undoing changes.
  4. Save and quit the file.
  5. Write down the commands you used.

πŸ—£οΈ Classroom Discussion Questions

  1. Why do you think vi is still used today?
  2. What are the advantages of using a terminal-based editor?
  3. How can learning vi help you in your career?
  4. What was the most challenging thing about learning vi?
  5. How do you think you can use vi in the future?

πŸ—οΈ Mini Project

Project: Create a vi Command Poster.

Instructions:

  1. Create a poster that teaches the most important vi commands.
  2. Include: how to open, save, quit, navigate, edit, and search.
  3. Add drawings and simple language.
  4. Share your poster with the class.

πŸ“‹ Practical Assignment

Assignment: vi Practice Report.

Instructions:

  1. Practice using vi to create and edit files.
  2. Write a report on what you did.
  3. Include: the commands you used and what they did.
  4. Submit your report to the teacher.

πŸ† Challenge Exercise

Challenge: The vi Challenge.

Instructions:

  1. Create a file with at least 10 lines of text.
  2. Practice navigating, deleting, copying, and pasting.
  3. Search for a word and replace it.
  4. Save and quit the file.
  5. Write down all the commands you used.
  6. Share your experience with the class.

πŸ”‘ Quiz Answers

Fill-in-the-Blank Answers:

  1. text
  2. command
  3. i
  4. Esc
  5. :w
  6. :q
  7. :wq
  8. dd
  9. u
  10. /

True or False Answers:

  1. True
  2. False
  3. False
  4. True
  5. True
  6. False
  7. True
  8. False
  9. True
  10. True

Multiple Choice Answers:

  1. B
  2. B
  3. B
  4. A
  5. A
  6. B
  7. C
  8. B
  9. B
  10. A
  11. B
  12. A
  13. A
  14. A
  15. A

🎯 Key Takeaways

  • vi is a powerful text editor.
  • vi has two modes: command mode and insert mode.
  • Press "i" to enter insert mode.
  • Press "Esc" to enter command mode.
  • Use ":w" to save, ":q" to quit, ":wq" to save and quit.
  • Use h, j, k, l to navigate.
  • Use x, dd, dw, u, yy, p to edit.
  • Use "/" to search.
  • Practice regularly to become comfortable with vi.
  • vi is a valuable skill for Linux users.

πŸ”œ Preparation for the Next Module

Congratulations on completing Module Four!

In the next module, Module Five: User and Group Management, you will learn how to manage users and groups on a Linux system. You will discover:

  • What users and groups are.
  • How to add, modify, and delete users.
  • How to add, modify, and delete groups.
  • How to manage user passwords.
  • How to control user permissions.

Get ready to manage users and groups!


End of Module Four πŸŽ“

vi is a powerful tool that every Linux user should learn!

πŸ† Get Certified

πŸ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

πŸŽ“ Sign Up to Get Certified
πŸ› οΈ Practice Tools
Hands-on simulators & labs - subscription required.
β†’
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
β†’