
Vim Modes
What are vim motions?
You may have noticed that inside a file you’re editing with nvim, you can’t use the mouse by itself, and you can’t always edit the document content. Why is that?
Inside nvim there are the so-called “modes” — five different ways to
interact with the document, each existing for a specific purpose. Below
I’ll describe each mode and how to use them to get the most out of this
editor.
Normal Mode
Normal mode is used mainly for navigating through the document using
specific keys. By default these are j to move down,
k to move up, h to move left, and l to
move right. It is important to note that uppercase and lowercase
letters have different functions, and all keyboard shortcuts can be
modified through keymaps.
Insert Mode
As the name suggests, insert mode is for inserting or modifying document content. There are several ways to enter it:
- a: Insert to the right of the current cursor position.
- i: Insert to the left of the current cursor position.
- o: Add a new line below the cursor and start inserting.
There are also uppercase variants:
- A: Insert at the end of the line.
- I: Insert at the beginning of the line.
- O: Add a new line above the cursor and start inserting.
To exit insert mode, simply press Esc.
Visual Mode
Visual mode is very similar to normal mode — you can’t freely edit like in insert mode. However, when you enter visual mode you’ll notice the first difference: as you move in any direction over text, it becomes highlighted. Visual mode is mostly used for selecting text, usually to copy or delete large sections in one step. Enter visual mode with v, and exit the same way as insert mode with Esc.