0
0
Linux CLIscripting~20 mins

vim basics (insert, command, save, quit) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Vim Basics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output after saving and quitting in Vim?
You open a file in Vim, enter insert mode, type Hello World, then save and quit. What will be the content of the file?
Linux CLI
vim example.txt
# In Vim:
# Press i
# Type Hello World
# Press Esc
# Type :wq
# Press Enter
AThe file is empty
BThe file contains the text: Hello World
CThe file contains the text: :wq
DThe file contains the text: iHello World
Attempts:
2 left
💡 Hint
Remember that typing i enters insert mode and :wq saves and quits.
💻 Command Output
intermediate
2:00remaining
What happens if you quit Vim without saving?
You open a file in Vim, enter insert mode, type some text, then try to quit with :q. What will Vim do?
Linux CLI
vim example.txt
# In Vim:
# Press i
# Type Some text
# Press Esc
# Type :q
# Press Enter
AVim will show a warning and not quit
BVim will save changes and quit
CVim will quit and discard changes
DVim will enter insert mode again
Attempts:
2 left
💡 Hint
Think about what Vim does when you try to quit with unsaved changes.
📝 Syntax
advanced
1:30remaining
Which Vim command saves the file without quitting?
You want to save your changes in Vim but keep editing. Which command do you use?
A:w
B:q
C:wq
D:x
Attempts:
2 left
💡 Hint
Think about the command that writes changes but does not exit.
💻 Command Output
advanced
1:00remaining
What is the effect of pressing in Vim?
You are in insert mode typing text in Vim. What happens when you press the key?
AYou quit Vim
BYou save the file
CYou exit insert mode and return to normal mode
DYou enter visual mode
Attempts:
2 left
💡 Hint
Think about how to stop typing text and use commands.
🚀 Application
expert
2:30remaining
How to save a file with a new name and quit Vim?
You opened a file in Vim but want to save your changes to a new file named newfile.txt and then quit. Which command do you use?
A:w newfile.txt
B:wq newfile.txt
C:saveas newfile.txt
D:w newfile.txt | :q
Attempts:
2 left
💡 Hint
Think about how to write to a new file and then quit in two steps.