Vim Tips Wiki

Jump to a line number

1,623pages on
this wiki
Add New Page
Add New Page Talk0
Tip 336 Printable Monobook Previous Next

created October 3, 2002 · complexity basic · author Odyss · version 5.7

An easy way to to get to a line (whose number we know) faster is to combine some existing methods:


The solution is to map the <Enter> key in Normal Mode, to the G command:

:nnoremap <CR> G

We can type the line number and then press Enter to get there. Without the mapping, 123<Enter> will jump 123 lines down from the current position rather than to an absolute number. With the mapping, you can jump very quickly...especially if you use the numeric keypad. On some systems, to get the numeric keypad's Enter button working, you may need to add the following mapping to make it do the same as the "normal" enter key (or <CR> as in the mapping above):

:nmap <kEnter> <Enter>

To launch Vim and start at a certain line, you can pass the line number as follows:

vim -c ":123"


Also on Fandom

Random Wiki