2018-10-04 13:47:55 +00:00
|
|
|
---
|
|
|
|
title: Navigation
|
|
|
|
---
|
|
|
|
|
|
|
|
## Vim Navigation
|
|
|
|
|
|
|
|
### Basic movement
|
|
|
|
|
|
|
|
There are many ways to move the cursor in Vim, but these basic movements will allow
|
|
|
|
new users to get comfortable using normal mode for file navigation.
|
|
|
|
|
|
|
|
* In normal mode, the keys `h`, `j`, `k` , `l` correspond to moving the cursor
|
|
|
|
one character left, down, up, and right, respectively.
|
|
|
|
|
|
|
|
* To navigate one word at a time, the keys `w`, and `b` will move the cursor to
|
|
|
|
the beginning of the next word, or the beginning of the previous word. The `e`
|
|
|
|
key will move the cursor to the end of the current word.
|
|
|
|
|
|
|
|
* To move to the beginning of the current line, type `0`, and to move to the end
|
|
|
|
of the current line, type `$`.
|
|
|
|
|
|
|
|
* Finally, to move to the first line in the file, type `gg`, and to move to the
|
|
|
|
last line in the file, type `G`.
|
|
|
|
|
|
|
|
In summary:
|
|
|
|
|
|
|
|
```vim
|
|
|
|
h moves one character left
|
|
|
|
j moves one row down
|
|
|
|
k moves one row up
|
|
|
|
l moves one character right
|
|
|
|
|
|
|
|
w moves to the beginning of the next word
|
|
|
|
b moves to the beginning of the previous word
|
|
|
|
e moves to the end of the current word
|
|
|
|
|
|
|
|
0 moves to the beginning of the current line
|
|
|
|
$ moves to the end of the current line
|
2018-10-11 23:00:38 +00:00
|
|
|
:n moves to line n (ex. :23 moves to line 23) can also use nG
|
2018-10-14 16:18:42 +00:00
|
|
|
^ moves to the first non blank character of the line.
|
2018-10-11 23:00:38 +00:00
|
|
|
|
2018-11-17 09:55:03 +00:00
|
|
|
ZZ moves to the center of the line you are on
|
2018-10-11 23:00:38 +00:00
|
|
|
H moves to the top of the screen
|
|
|
|
M moves to the middle of the screen
|
|
|
|
L moves to the bottom of the screen
|
2018-10-04 13:47:55 +00:00
|
|
|
|
|
|
|
gg moves to the first line in the file
|
|
|
|
G moves to the last line in the file
|
|
|
|
```
|
|
|
|
|