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:

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

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

Move cursor downj

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:


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

Move cursor to the right4l

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