Vim is a highly customizable and efficient text editor that is popular among developers and power users. One of Vim’s standout features is its extensive set of keyboard shortcuts and commands, referred to as “key bindings.” Mastering these key bindings can greatly improve your productivity when editing files in Vim.

We will cover the most important and commonly used Vim key bindings to help you become a Vim ninja.

Basic Navigation

The most basic key bindings allow you to navigate through a document. Here are some of the main ones:

  • h - Move left
  • j - Move down
  • k - Move up
  • l - Move right

You can hold down the arrow keys for quicker continuous movement.

  • Ctrl + f - Page down
  • Ctrl + b - Page up
  • 0 (zero) - Move to beginning of line
  • $ - Move to end of line
  • gg - Go to beginning of file
  • G - Go to end of file

Insert Mode

To enter Insert mode to start typing, press i. To exit back to Normal mode, press Esc.

Some other useful Insert mode shortcuts:

  • i - Insert before cursor
  • I - Insert at beginning of line
  • a - Append after cursor
  • A - Append to end of line
  • o - Open new line below
  • O - Open new line above

Editing Text

Now let’s look at some key bindings that allow you to edit text:

  • x - Delete character

  • dw - Delete word

  • dd - Delete line

  • d$ - Delete to end of line

  • d0 - Delete to beginning of line

  • c - Change/replace

  • cw - Change current word

  • cc - Change entire line

  • u - Undo

  • Ctrl + r - Redo

  • y - Yank/copy

  • yy - Yank current line

  • p - Paste

  • . - Repeat last command

Searching

Vim offers some handy search functionalities:

  • /pattern - Search forward
  • ?pattern - Search backward
  • n - Next match
  • N - Previous match

Use * to search for the word under cursor:

  • * - Search forward for word under cursor
  • # - Search backward

Exiting

To save and quit:

  • :w - Save file
  • :wq - Save and quit
  • :q! - Quit without saving

Vim’s key bindings allow you to edit text at the speed of thought. You now have a solid foundation of the most important and commonly used key bindings in Vim. Refer to this reference often as you continue to master this powerful editor. The more you practice using these shortcuts, the more efficient you will become editing files in Vim.