Vim Tips Wiki
(Remove html character entities)
(Undo revision 37864 by 115.248.25.122 (talk) - searching with '/' for a line number will NOT work, and restoring useful content, and expanding on the <CR> method)
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{review}}
 
 
{{TipImported
 
{{TipImported
 
|id=336
 
|id=336
Line 23: Line 22:
 
The solution is to map in normal mode the enter to G.
 
The solution is to map in normal mode the enter to G.
 
<pre>
 
<pre>
:nmap <CR> G
+
:nnoremap <CR> G
 
</pre>
 
</pre>
   
  +
We can type the line number and then press Enter to get there. Without the mapping, <code>123<Enter></code> 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):
We can type the line number and then press Enter to get there.
 
   
  +
<pre>
==Comments==
 
  +
:nmap <kEnter> <Enter>
Though
 
  +
</pre>
:123[Enter]
 
takes you to line 123 in the file,
 
   
 
==Comments==
123[Enter]
 
takes you 123 lines down from your present position.
 
 
----
 

Revision as of 14:02, 26 September 2014

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>

Comments