From the course: Learning vi

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Moving the cursor

Moving the cursor - vi Tutorial

From the course: Learning vi

Start my 1-month free trial

Moving the cursor

Now I'm going to show you how to move your cursor around using vi. In command mode, we make use of the characters H, J, K, and L. These four keys are almost right under your right hand if you have your fingers on the home row. They're interpreted as follows. k goes up by one line. j goes down by one line. h goes to the left by one character. l goes to the right by one character. These keys have these meanings because on the ADM-3A terminal on which vi was original written, those keys were labeled with arrows indicating that motion. And this same HJKL syntax from moving the cursor around is found in a lot of other programs from that era. So let's just demonstrate those. We'll edit our Duke of York file again. And now I can show you how we can go down with j, j, j, j. To the right with l, l, l, l. Up with k, k, k, k. And to the left with h, h, h, h. In addition to h, l, k and j, you have several other alternatives for moving by one line or one character. You can use the arrow keys on…

Contents