Skip to content

Vim Beginner's Guide

Vim is a powerful text editor available on almost every Linux system. This guide covers the basics to get you started.

Opening and Exiting Vim

ActionCommand
Open a filevim filename.txt
Open Vim (no file)vim
Quit:q
Quit without saving:q!
Save and quit:wq or ZZ
Save (write):w

Vim Modes

Vim has several modes. The two most important are:

  • Normal mode: For navigation and commands (default when you open Vim)
  • Insert mode: For typing text (press i to enter)
To enter...Press...
Insert modei
Normal modeEsc

Basic Navigation

KeyWhat it does
hLeft
jDown
kUp
lRight
0Start of line
$End of line
ggTop of file
GBottom of file
wNext word
bPrevious word

Editing Text

ActionCommand
Enter insert modei (before cursor)
a (after cursor)
Delete characterx
Delete linedd
Undou
RedoCtrl+r
Copy (yank) lineyy
Pastep
Cut (delete) worddw
Replace charr then new char

Searching

ActionCommand
Search for text/text
Next matchn
Previous matchN

Visual Mode (Selecting Text)

  • Press v to start selecting (character-wise)
  • Press V for line-wise selection
  • Use movement keys to expand selection
  • Press y to copy, d to cut, or p to paste after selection

Useful Tips

  • Press Esc to return to normal mode at any time
  • Use :help in Vim for built-in documentation
  • To edit multiple files: vim file1.txt file2.txt
  • To split window: :vsp filename (vertical), :sp filename (horizontal)
  • To open file explorer: :Ex or :Explore
  • To repeat last command: . (dot)

Getting Better

  • Try the Vim tutorial: run vimtutor in your terminal
  • Practice! Vim is tricky at first but very fast once you learn the basics
  • Explore plugins and customizations as you get comfortable

For more, see Vim Adventures (game), Open Vim, or the official Vim documentation.

Released under Creative Commons Zero v1.0 Universal License.