vim is the editor that runs in your terminal. Learn how to get out with `:q!`, how the modes work, and the handful of movement and editing keys worth knowing, in a real terminal in your browser.
Updated: 2026-09-06
vim [+line] [file]
It opens the file. A name that does not exist yet opens as a new file.
Have a look at the file before editing it.
$ cat notes.txt
buy milk
call the bank
fix the login bug
Now open it.
$ vim notes.txt
The screen turns into the editor. The first thing to learn is how to leave.
| What you want | What to press |
|---|---|
| Quit without saving | Esc → :q! → Enter |
| Save and quit | Esc → :wq → Enter |
| Just save | Esc → :w → Enter |
Esc comes first because it takes you back to normal mode from wherever you were.
What makes vim different from other editors is that keys mean different things in different modes.
| Mode | What it is for | How to get there |
|---|---|---|
| Normal | Moving, deleting, copying | Esc |
| Insert | Typing text | i (before the cursor), a (after), o (new line below) |
| Command line | Saving, quitting, substituting | : |
A freshly opened file is in normal mode.
Type there and your letters are read as commands instead of text.
That is the part everyone trips on, and the whole answer is: i to write, Esc when you are done.
In normal mode, single keys move the cursor.
| Key | Movement |
|---|---|
h j k l | Left, down, up, right |
w b | Forward and back one word |
0 $ | Start and end of the line |
gg G | Top and bottom of the file |
/text then Enter | Search forward; n for the next match |
Arrow keys work too, but h j k l keep your hands still.
| Key | What it does |
|---|---|
x | Delete the character under the cursor |
dd | Delete the whole line |
dw | Delete a word |
yy then p | Copy a line and paste it |
ciw | Delete the word and start typing in its place |
u | Undo |
Ctrl+r | Redo |
. | Repeat the last change |
Deleting and pasting in one or two keystrokes is the reason people call vim fast.
When you know which line the error is on, open there.
$ vim +12 logs/app.log
+12 puts the cursor on line 12 as the file opens.
vim is what you type to fix a config file on a machine you reached over SSH.
| Situation | What to type |
|---|---|
| Edit a config file | vim config.yml |
| Open at the line from a log | vim +12 logs/app.log |
| Start a new file | vim draft.txt |
| Only reading | use cat or less instead |
Read with less, change with vim, and you will rarely have to think about which one.
Press Esc before :.
Type :wq while still in insert mode and it goes into the file as text.
If saving does not seem to work, Esc first.
Ctrl+S does nothing useful.
In a terminal it can freeze the display instead.
Saving is :w.
Directories cannot be opened.
$ vim logs
vim: logs: Is a directory
:q! is the escape hatch.
:q refuses to quit while there are unsaved changes.
When you have lost track of what you did, Esc then :q! puts the file back the way it was.
webterm.appthis site
Vim Basics
Open, edit, save, and quit Vim
Vim Editing
Delete, copy, undo, and replace text
learn.webterm.appa separate site

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the course