Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (30 sloc) 1.58 KB
<h3 id="basic-navigation">Basic Navigation</h3>
<p>You want to move around inside a file.</p>
<p>The traditional approach is to use the arrow keys to move up, down, left,
and right. Vim supports that style of navigation but also offers a more
efficient alternative:</p>
<tr><th>Key</th> <th>Movement</th></tr>
<tr><td><kbd>h</kbd></td> <td>Left</td></tr>
<tr><td><kbd>l</kbd></td> <td>Right</td></tr>
<tr><td><kbd>k</kbd></td> <td>Up a line</td></tr>
<tr><td><kbd>j</kbd></td> <td>Down a line</td></tr>
<tr><td><kbd>0</kbd></td> <td>Start of line</td></tr>
<tr><td><kbd>^</kbd></td> <td>First character of line</td><tr>
<tr><td><kbd>$</kbd></td> <td>End of line</td></tr>
<p>It is tempting to rely on old habits for something as basic as moving
around in a file. Once you're used to The Vim Way, however, you'll find
yourself much more efficient. One reason for this is that these keys are all
located on the main keyboard, so you don't need to stretch to the arrow keys,
hence breaking your flow.</p>
<p>Another benefit is that you can prefix these shortcuts with <i>counts</i> (as
you can with many Vim commands) which specify how many times they should be
executed. For instance, <kbd>2k</kbd> moves up two lines. </p>
<p>Once you've become used to these keys, take a look at <i>motions</i> and
<i>text objects</i> in <a href="#selecting-text-with-motions">Selecting Text
with Motions</a> to make the humble combination of <kbd>h</kbd>,
<kbd>l</kbd>, <kbd>k</kbd>, and <kbd>j</kbd> more powerful still.</p>