Basic Cursor Movement

We learned about modes in the fundamentals chapter. In Vim, basic navigation is performed in normal mode, which you can get to from (almost) any situation by hitting the Esc key.

The most basic cursor movements (known as motions in Vim) are those used to move the cursor in small increments within a buffer. Most Vim distributions also support using the arrow keys for simple cursor movements, but it is good practice to ignore the arrows and get used to using these:

CommandAction
hcursor N chars to the left
lcursor N chars to the right
jcursor N lines downward
kcursor N lines upward

Moving the cursor

As a simple demo of basic cursor movements, we can start from the following buffer:

Initial Conditions
We·are·not·going·in·circles,·we·are·going·upwards.
The·path·is·a·spiral;·we·have·already·climbed·many·steps.
NORMAL
Top
1:1
 

Hitting the j key moves the cursor down one line, as described above:

Move cursor down
j
We·are·not·going·in·circles,·we·are·going·upwards.
The·path·is·a·spiral;·we·have·already·climbed·many·steps.
NORMAL
67%
2:1
 

Using Counts

Now, suppose you want to move the cursor 4 columns to the right. One option is to type l 4 times, but Vim provides a better way, called counts.

Vim motions accept a count, which precedes the motion and specifies how many times to repeat the motion, following the basic pattern:

[count][motion]

So, rather than hitting l l l l, one can simply type 4l:

Move cursor to the right
4l
We·are·not·going·in·circles,·we·are·going·upwards.
The·path·is·a·spiral;·we·have·already·climbed·many·steps.
NORMAL
67%
2:5
 

Note that the default count is 1, allowing the count to be omitted as in the first example.