Survival: Open, Edit, Save, Quit
The Survival Sequence
This is the whole game. Memorize this one flow and you can edit any file anywhere:
- Open:
vim notes.txt - Insert mode: press
i- now type normally - Stop typing: press
Esc(back to Normal) - Save & quit: type
:wqthenEnter
The command-mode escape hatches (from Normal, after Esc):
| Type this | Result |
|---|---|
:w | Write (save), stay open |
:q | Quit (only if no unsaved changes) |
:wq or :x | Save and quit |
:q! | Quit and throw away changes |
Danger: :q! discards everything since your last save. It's your "get me out, I don't care" button - powerful, but don't use it out of habit or you'll lose real work.
$ vim hello.txt
# press i, type: Hello Linux
# press Esc, type :wq and Enter
$ cat hello.txt
Hello Linux
Goal: In the terminal below: create a file with vim, type a line, save it with:wq, and confirm withcat. That single loop is 90% of daily editing.