Vim Tips Wiki
Register
(Move categories to tip template)
(Change <tt> to <code>, perhaps also minor tweak.)
(9 intermediate revisions by 6 users not shown)
Line 2: Line 2:
 
|id=10
 
|id=10
 
|previous=9
 
|previous=9
|next=11
+
|next=12
|created=February 24, 2001
+
|created=2001
 
|complexity=basic
 
|complexity=basic
 
|author=Yegappan
 
|author=Yegappan
|version=5.7
+
|version=6.0
 
|rating=278/86
 
|rating=278/86
 
|category1=
 
|category1=
 
|category2=
 
|category2=
 
}}
 
}}
Vim remembers all the locations visited by you in a file in a single Vim session. You can jump to the older locations by pressing the Ctrl-O key. You can jump to the newer locations by pressing the Ctrl-I or the &lt;Tab&gt; key.
+
Vim remembers the locations you have recently visited (where you jumped from). Each position (file name, column number, line number) is recorded in a jump list, and each window has a separate jump list that records the last 100 positions where a jump occurred.
  +
  +
The commands that are regarded as "jumps" include searching, substitute and marks. Scrolling through a file is not regarded as jumping.
  +
  +
The jump list is saved between edits (provided the <code>'viminfo'</code> option has the '''<code>'</code>''' parameter), so you can see where jumps occurred from previous editing sessions. {{help|'viminfo'}}
  +
  +
==Using a jump list==
  +
Like a web browser, you can go back, then forward:
  +
*Press Ctrl-O to jump back to the previous (older) location.
  +
*Press Ctrl-I (same as Tab) to jump forward to the next (newer) location.
  +
  +
Display the jump list for the current window with:
  +
<pre>
  +
:jumps
  +
</pre>
  +
  +
Your current location in the jump list is indicated with '<code>></code>', and the first number in each row is a count that can be used to jump to that position. For example, after pressing Ctrl-O three times, the <code>:jumps</code> command may show something like this:
  +
<pre>
  +
jump line col file/text
  +
4 102 0 somefile.txt
  +
3 93 0 -invalid-
  +
2 23 0 the current line 23 is shown here
  +
1 89 34 the current line 89 is shown here
  +
> 0 22 40 Display the jump list for the current window with:
  +
1 39 0 the current line 39 is shown here
  +
2 995 0 anotherfile.txt
  +
3 53 102 the current line 53 is shown here
  +
</pre>
  +
  +
Given the above, you could press:
  +
*Ctrl-I to jump to line 39 in the current buffer.
  +
*Ctrl-O to jump to line 89 in the current buffer.
  +
*<code>4</code> then Ctrl-O to jump to line 102 in file <code>somefile.txt</code>.
  +
*<code>3</code> then Ctrl-I to jump to line 53 in the current buffer.
  +
  +
In the example above:
  +
*The last line was added to the jump list when the first Ctrl-O was pressed (so you can return to the initial position: line 53, column 102).
  +
*Line 93 in the current buffer no longer exists (the jump location is invalid).
  +
  +
==See also==
  +
*[[VimTip42|Using marks]] to manually record ''marks'' that you can return to
  +
*[[VimTip1300|List changes to the current file]] the change list records where changes occurred
   
 
==References==
 
==References==
*{{help|CTRL-O}}
 
*{{help|CTRL-I}}
 
 
*{{help|jump-motions}}
 
*{{help|jump-motions}}
 
*{{help|jumplist}}
 
*{{help|:jumps}}
   
 
==Comments==
 
==Comments==
  +
  +
You can also use <code>g;</code> and <code>g,</code> to move backward and forward in your edit locations.

Revision as of 05:06, 13 July 2012

Tip 10 Printable Monobook Previous Next

created 2001 · complexity basic · author Yegappan · version 6.0


Vim remembers the locations you have recently visited (where you jumped from). Each position (file name, column number, line number) is recorded in a jump list, and each window has a separate jump list that records the last 100 positions where a jump occurred.

The commands that are regarded as "jumps" include searching, substitute and marks. Scrolling through a file is not regarded as jumping.

The jump list is saved between edits (provided the 'viminfo' option has the ' parameter), so you can see where jumps occurred from previous editing sessions. :help 'viminfo'

Using a jump list

Like a web browser, you can go back, then forward:

  • Press Ctrl-O to jump back to the previous (older) location.
  • Press Ctrl-I (same as Tab) to jump forward to the next (newer) location.

Display the jump list for the current window with:

:jumps

Your current location in the jump list is indicated with '>', and the first number in each row is a count that can be used to jump to that position. For example, after pressing Ctrl-O three times, the :jumps command may show something like this:

 jump line  col file/text
   4   102    0 somefile.txt
   3    93    0 -invalid-
   2    23    0 the current line 23 is shown here
   1    89   34 the current line 89 is shown here
>  0    22   40 Display the jump list for the current window with:
   1    39    0 the current line 39 is shown here
   2   995    0 anotherfile.txt
   3    53  102 the current line 53 is shown here

Given the above, you could press:

  • Ctrl-I to jump to line 39 in the current buffer.
  • Ctrl-O to jump to line 89 in the current buffer.
  • 4 then Ctrl-O to jump to line 102 in file somefile.txt.
  • 3 then Ctrl-I to jump to line 53 in the current buffer.

In the example above:

  • The last line was added to the jump list when the first Ctrl-O was pressed (so you can return to the initial position: line 53, column 102).
  • Line 93 in the current buffer no longer exists (the jump location is invalid).

See also

References

Comments

You can also use g; and g, to move backward and forward in your edit locations.