Vim stands for "Vi IMproved". It is a keyboard-driven editor that runs in any terminal. It feels strange at first for one reason: it has modes. Once that clicks, the rest is practice.
Starting Vim
vim notes.txtIf notes.txt exists, Vim opens it. If not, you get an empty buffer, and the file is created when you first save. A buffer is the copy of the text that Vim holds in memory. Your changes reach the disk only when you write them.
Empty lines past the end of the text are marked with ~. Those are not characters in your file.
If the vim command is not found, try vi. Debian and Ubuntu may provide only a small build as vi, which lacks some features and behaves more like the original. Install the vim package (Fedora: vim-enhanced) for the full editor.
The modes
- Normal mode is where you start. Keys are commands: move, delete, copy.
- Insert mode is for typing text. Press
ito enter it. - Visual mode is for selecting text. Press
v. - Command-line mode is for commands such as save and quit. Press
:and the command appears at the bottom.
Press Esc to return to Normal mode. If you are unsure where you are, press Esc and you are on safe ground.
In full Vim, the bottom line tells you when you are typing text:
-- INSERT --A first edit
- Run
vim hello.txt. - Press
i. - Type
Hello from Vim. - Press
Esc. - Type
:wqand pressEnter.
w writes the file and q quits. Check the result:
$ cat hello.txt
Hello from VimIf you want to leave without keeping changes, press Esc, then type :q! and Enter.
Getting help
Inside Vim, :help opens the built-in manual and :q closes the help window. :help i explains the i command. Small builds may not include the help files.
Full Vim packages also ship a hands-on tutorial. Run this from the shell:
vimtutorIt opens a copy of a practice file, so you can experiment freely.
Try it
- Open
hello.txtagain withvim hello.txt. - Press
i, add a few words, then pressEsc. - Quit without saving using
:q!. - Run
cat hello.txtand confirm that your new words are not there. - If
vimtutoris available, work through its first lesson.
Check your understanding
Vim (Vi Improved)
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.