Fandom

Vim Tips Wiki

Jump to a line number

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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 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 file.xxx -c ":123"

CommentsEdit

Also on Fandom

Random Wiki