Learning cursor movement in VIM text editor

Unix

In vim text editor we can control the cursor and accomplish some cool movements in few key press. So, lets start learning few of the tricks that will help us in moving the cursor in vim easily.

Open a file in vim

For this tutorial we will open the hello.txt file which contain some text.

$ vim hello.txt

How to move the cursor up and down in vim?

To move the cursor up we can use the up arrow key and k. Similarly to move the cursor down we can use the down arrow key and j.

How to move the cursor left and right in vim?

To move the cursor left we can use the left arrow key and h. Similarly to move the cursor right we use the right arrow key or l.

How to move to the last line in a file in vim?

To move to the last line in a file in vim type G

How to move to the first line in a file in vim?

To move to the first line in a file in vim type 1G

How to move to the nth line in a file in vim?

To move to the nth line in a file in vim type nG where n is any integer denoting the line number, i.e., 1 for first line, 2 for second line and so on.

How to move to the end of a current line in a file in vim?

To move to the end of a current line in a file in vim type $

How to move to the beginning of a current line in a file in vim?

To move to the end of a current line in a file in vim type 0

How to move down one page in a file in vim?

To move down one page in a file in vim press Ctrl+f

How to move up one page in a file in vim?

To move down one page in a file in vim press Ctrl+b

How to move to the beginning of next word in a file in vim?

To move to the beginning of the next word or punctuation in vim simply type w

How to move to the beginning of previous word in a file in vim?

To move to the beginning of the previous word or punctuation in vim simply type b

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT