Moving the cursor
In this lesson, we’re going to explore basic navigation in Vim. Vim provides us with lots of ways to move around the document, but we’ll start from the beginning.
The first thing to learn is how to move around with the keyboard. Since Vim is a terminal-first application, you can do absolutely everything without ever having to touch the mouse.
The simplest possible navigation is moving the cursor up, down, left, and right from its current position. In Vim, you can do this with either:
- the arrow keys, just like in other editors
h,j,k, andlto move one character right, down, up, and left respectively
Give the basic movement commands a try in the editor!
You might be wondering: should I use the arrow keys, or should I use hjkl? The truth is that it doesn’t matter too much at this early stage in the learning process. That said, seasoned Vim users usually prefer hjkl, because your fingers don’t leave the home row on your keyboard. Incorporating hjkl into your workflow will make you faster, but it can be tricky to build up the muscle memory. At the moment, use the arrow keys if it’s more comfortable.