8. Vim Saving and Exiting
Lesson Content
Now that you’ve done your editing it’s time to actually save and quit out of vim:
-
:w - writes or saves the file
-
:q - quit out of vim
-
:wq - write and then quit
-
:q! - quit out of vim without saving the file
-
ZZ - equivalent of :wq, but one character faster
-
u - undo your last action
-
Ctrl-r - redo your last action
You may not think ZZ is necessary, but you’ll eventually see that your fingers may tend to lean towards this rather than :wq.
Whew that was a lot of information to take about Vim. Now that you know some basic commands and navigation, you can start editing some text files. There are many more options you can use in vim to increase your ability to master this text editor, head on to Vim’s online guide to take a look.
Exercise
No exercises for this lesson.
Quiz Question
# How do you quit out of vim without saving?
> Remember Esc : As mentioned above, pressing Esc is a key step in exiting Vim. If you are having trouble exiting insert mode or entering commands, try pressing Esc first to return to normal mode. Use ``` :q ```
1. [ ] :d
2. [ ] :x
3. [ ] :q
4. [x] :q!