How do I move the cursor to a specific row and column?

:30 will move my cursor to the beginning of line 30.

How can I tell Vim to place the cursor at line y, column x? Is this possible without using the arrow keys or h, j, k, l keys?

I am running Vim version 7.3.429.


Solution 1:

Try a number followed by a pipe to get to the specified column in that line.

80| should get you to position 80 in that line.

EDIT: If you are looking to go to a specific x,y position, I am not sure on that one.

Solution 2:

Not sure it's in any way more convenient, but you can call the cursor function directly:

:cal cursor(30, 5)

will jump to line 30, column 5.

Solution 3:

In command mode:

Type a number followed by G (uppercase) to go to that line number.
Example: 30G goes to line 30.
Example: G goes to the last line of the buffer.

Type a number followed by | (pipe) to go to that column in the current line.
Example: 80| goes to column 80.

So: 30G80| goes to line 30, column 80.

Solution 4:

Another option using execute <line_num>. For example,

function GotoLine(line)
     execute a:line
endfunction