Getting Started·Lesson 1
Intro to Modes
modesThe first idea to get comfortable with is modes. The same key does different things depending on which mode you are in.
Normal mode
This is home base. Keys are commands here, not text. You use it to:
- move the cursor around
- delete, change and copy text
- combine small commands into bigger edits
1const total = price * quantity;
2if (total > limit) {
3 notify("over budget", total);
4}
Pressing keys in normal mode moves the cursor; nothing gets typed.
Insert mode
This is the mode you already know from other editors: what you type goes into the file. Press i to enter it and Esc to go back to normal mode.
1const total = price * quantity;
2if (total > limit) {
3 notify("over budget", total);
4}
`i` starts inserting, `Esc` returns to normal mode.
Rule of thumb
You'll spend most of your time in normal mode. Think of insert mode as a short trip: go in, type, come straight back out.
Try it out
1const total = price * quantity;
2if (total > limit) {
3 notify("over budget", total);
4}
# Why have modes at all?
Because when letters aren't busy typing text, every key on the keyboard can be a command. That's how Vim edits so much with so few keystrokes.