Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (30 sloc) 1.616 kb
1f3b741 @runpaint Final pass over Navigation chapter before release.
authored
1 <h3 id="basic-navigation">Basic Navigation</h3>
2
3 <h4>Problem</h4>
4
5 <p>You want to move around inside a file.</p>
6
7 <h4>Solution</h4>
8
9 <p>The traditional approach is to use the arrow keys to move up, down, left,
10 and right. Vim supports that style of navigation but also offers a more
11 efficient alternative:</p>
12
13 <table>
14 <tr><th>Key</th> <th>Movement</th></tr>
15 <tr><td><kbd>h</kbd></td> <td>Left</td></tr>
16 <tr><td><kbd>l</kbd></td> <td>Right</td></tr>
17 <tr><td><kbd>k</kbd></td> <td>Up a line</td></tr>
18 <tr><td><kbd>j</kbd></td> <td>Down a line</td></tr>
19 <tr><td><kbd>0</kbd></td> <td>Start of line</td></tr>
20 <tr><td><kbd>^</kbd></td> <td>First character of line</td><tr>
21 <tr><td><kbd>$</kbd></td> <td>End of line</td></tr>
22 </table>
23
24 <h4>Discussion</h4>
25
26 <p>It is tempting to rely on old habits for something as basic as moving
27 around in a file. Once you're used to The Vim Way, however, you'll find
28 yourself much more efficient. One reason for this is that these keys are all
29 located on the main keyboard, so you don't need to stretch to the arrow keys,
30 hence breaking your flow.</p>
31
32 <p>Another benefit is that you can prefix these shortcuts with <i>counts</i> (as
33 you can with many Vim commands) which specify how many times they should be
34 executed. For instance, <kbd>2k</kbd> moves up two lines. </p>
35
36 <p>Once you've become used to these keys, take a look at <i>motions</i> and
37 <i>text objects</i> in <a href="#selecting-text-with-motions">Selecting Text
38 with Motions</a> to make the humble combination of <kbd>h</kbd>,
39 <kbd>l</kbd>, <kbd>k</kbd>, and <kbd>j</kbd> more powerful still.</p>
Something went wrong with that request. Please try again.