0
0
Linux CLIscripting~10 mins

vim basics (insert, command, save, quit) in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - vim basics (insert, command, save, quit)
Open vim
Normal mode
Press i
Insert mode
Type text
Press ESC
Back to Normal mode
Type :w to save
Type :q to quit
Exit vim
This flow shows how to open vim, switch between normal and insert modes, save changes, and quit.
Execution Sample
Linux CLI
vim example.txt
i
Hello, Vim!
<Esc>
:w
:q
Open vim, enter insert mode, type text, exit insert mode, save file, then quit vim.
Execution Table
StepActionModeEffectOutput/Result
1Open vim with 'vim example.txt'Normalvim opens in normal modeScreen shows empty buffer or file content
2Press 'i'InsertSwitch to insert modeCursor allows typing text
3Type 'Hello, Vim!'InsertText inserted into bufferBuffer now contains 'Hello, Vim!'
4Press <Esc>NormalReturn to normal modeCursor stops inserting text
5Type ':w' and press EnterNormalSave fileFile 'example.txt' saved
6Type ':q' and press EnterNormalQuit vimvim closes, back to shell
💡 vim closes after ':q' command
Variable Tracker
VariableStartAfter Step 3After Step 5Final
ModeNormalInsertNormalExited
Buffer Content"""Hello, Vim!""Hello, Vim!""Hello, Vim!" saved to file
Key Moments - 3 Insights
Why can't I type text immediately after opening vim?
vim starts in normal mode (see Step 1). You must press 'i' to enter insert mode before typing text (Step 2).
What does pressing <Esc> do?
Pressing <Esc> switches vim from insert mode back to normal mode (Step 4), stopping text insertion.
How do I save changes without quitting vim?
Use ':w' command in normal mode (Step 5) to save without exiting.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what mode is vim in after Step 2?
ANormal mode
BVisual mode
CInsert mode
DCommand mode
💡 Hint
Check the 'Mode' column at Step 2 in the execution table.
At which step is the file saved?
AStep 4
BStep 5
CStep 3
DStep 6
💡 Hint
Look for the ':w' command in the Action column.
If you forget to press <Esc> before ':w', what happens?
Avim inserts ':w' as text
Bvim quits without saving
Cvim saves the file anyway
Dvim shows an error
💡 Hint
Recall that commands like ':w' only work in normal mode (see Step 4 and 5).
Concept Snapshot
vim basics:
- Open file: vim filename
- Insert mode: press 'i' to type
- Normal mode: press <Esc> to stop typing
- Save file: type ':w' in normal mode
- Quit vim: type ':q' in normal mode
Remember: Insert mode for typing, Normal mode for commands.
Full Transcript
This lesson shows how to use vim basics. First, open vim with a file name. vim starts in normal mode where you cannot type text directly. Press 'i' to enter insert mode and type your text. When done, press the Escape key to return to normal mode. To save your changes, type ':w' and press Enter. To quit vim, type ':q' and press Enter. If you forget to press Escape before commands, vim will treat them as text. This flow helps you edit files safely and efficiently.