Wikia

Vim Tips Wiki

Jump to a line number

Talk0
1,613pages on
this wiki
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:

:123<CR>
or
123G
or
123gg

The solution is to map in normal mode the enter to G.

: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>

CommentsEdit

Around Wikia's network

Random Wiki