Quiz: Text Editors - Nano and Vim
Test your understanding of command-line text editors.
1. What makes nano a good choice for beginners?
- It's the fastest editor
- It displays shortcut hints at the bottom of the screen
- It has the most features
- It only works in graphical mode
Show Answer
The correct answer is B. Nano displays keyboard shortcuts at the bottom of the screen (like ^X for exit, ^O for save), making it intuitive for beginners. The ^ symbol means Ctrl, so ^X means Ctrl+X.
Concept Tested: Nano Editor
2. In nano, what does Ctrl+O do?
- Opens a new file
- Writes (saves) the current file
- Cuts a line
- Exits nano
Show Answer
The correct answer is B. Ctrl+O in nano writes (saves) the file. You'll be prompted to confirm the filename. Ctrl+X exits, and if you have unsaved changes, nano will ask if you want to save first.
Concept Tested: Nano Editor
3. What are vim's two main modes?
- Light mode and dark mode
- Normal (command) mode and insert mode
- Read mode and write mode
- User mode and admin mode
Show Answer
The correct answer is B. Vim has multiple modes, but the two main ones are Normal mode (for commands and navigation) and Insert mode (for typing text). Press i to enter insert mode, and Esc to return to normal mode.
Concept Tested: Vim Editor, Vim Modes
4. How do you save and quit in vim?
- Ctrl+S then Ctrl+Q
- :wq or :x (in normal mode)
- F2 then F10
- /save /quit
Show Answer
The correct answer is B. In vim's normal mode, type :wq (write and quit) or :x to save and exit. Use :w to save without quitting, or :q! to quit without saving (force quit).
Concept Tested: Vim Commands
5. In vim, what does pressing i do?
- Inserts a new line
- Enters insert mode at the cursor position
- Indents the current line
- Inverts text colors
Show Answer
The correct answer is B. Pressing i in vim's normal mode enters insert mode at the cursor position, allowing you to type text. Other insert options: a (after cursor), o (new line below), O (new line above).
Concept Tested: Vim Insert Mode
6. In vim's normal mode, what does dd do?
- Duplicates the current line
- Deletes the current line
- Downloads a file
- Displays documentation
Show Answer
The correct answer is B. In vim, dd deletes (cuts) the entire current line. The deleted line is stored in a buffer and can be pasted with p. Use 5dd to delete 5 lines at once.
Concept Tested: Vim Commands
7. How do you search for text in vim?
- Ctrl+F
- /searchterm (in normal mode)
- :find searchterm
- F3
Show Answer
The correct answer is B. In normal mode, type / followed by your search term and press Enter. Press n to go to the next match, N for the previous match. Use ? to search backwards.
Concept Tested: Vim Search
8. What does u do in vim's normal mode?
- Undoes the last change
- Uppercases text
- Updates the file
- Unindents a line
Show Answer
The correct answer is A. Pressing u in vim's normal mode undoes the last change. Press u multiple times to undo multiple changes. Use Ctrl+R to redo (undo the undo).
Concept Tested: Vim Commands
9. In vim, what does yy followed by p do?
- Types "yyp" literally
- Copies the current line and pastes it below
- Yanks a file from the internet
- Prints the file
Show Answer
The correct answer is B. In vim, yy "yanks" (copies) the current line, and p pastes it below the cursor. This is vim's copy-paste functionality. Use y with motions for partial yanks.
Concept Tested: Vim Copy and Paste
10. What should you do if you're stuck in vim and don't know how to exit?
- Close the terminal window
- Press Esc, then type :q! and press Enter
- Press Ctrl+Alt+Delete
- Unplug the computer
Show Answer
The correct answer is B. If you're stuck, press Esc to ensure you're in normal mode, then type :q! and press Enter. This force-quits vim without saving. Add :w first (:wq) if you want to save your work.
Concept Tested: Vim Commands