In Vim, normal arrow/cursor keys (←↓↑→) work as expected. However, for touch-typers, it's easier to use the hjkl alternative keys. On a typical keyboard, they're located next to each other on the same row, and easily accessible using right hand. The mnemonic technique to remember which is which among them goes like this:
All commands below should be done in normal mode.
Command | Description |
---|---|
h or left | go [count] characters to the left |
j or down | go [count] characters below |
k or up | go [count] characters above |
l or right | go [count] characters to the right |
gg | go the first line, or [count]'th line, if given |
H | go to the first line in the visible screen |
M | go to the middle line in the visible screen |
L | go to the last line in the visible screen |
G | go the last line, or [count]'th line, if given |
Home or 0 | go to first character of the line |
^ | go to first non-blank character of the line |
+ | go down one line to first non-blank character |
- | go up one line to first non-blank character |
$ or End | go to the end of the line (if [count] is given, go [count - 1] lines down) |
| | go to the [count]'th character or go to the beginning of the line if count not specified |
f{char} | go to [count]'th occurrence of {char} to the right inclusive |
F{char} | go to [count]'th occurrence of {char} to the left inclusive |
t{char} | go to [count]'th occurrence of {char} to the right exclusive |
T{char} | go to [count]'th occurrence of {char} to the left exclusive |
; | repeat latest f, t, F or T [count] times |
, | repeat latest f, t, F or T, in the opposite direction, [count] times |
w | go to the beginning of the next word |
b | go to the beginning of the previous word |
e | go to the ending of the next word |
ge | go to the ending of the previous word |
% | go to matching pairs, e.g (), [], {} , /* */ or #if, #ifdef, #else, #elif, #endif |
{ } | previous/next paragraph |
[{]} | beginning/ending of block |
'{char} | Go to mark (mark with m{char}) |
<C-B><C-F> | previous/next page |
<C-O><C-I> | Go back or foward in the "jump list" (requires jumplist feature, see :help jumps ) |
Note: b, e, and w consider a word to be letters, numbers, and underscores by default (this can be configured with the iskeyword
setting). Each of these can also be capitalized, causing them to skip over anything that isn't whitespace as well.
Note: Vim recognizes two kinds of movement: operator movement (:help movement
) and jumps (:help jumplist
). Movements like those executed with g
(gg
, G
, g,
) count as jumps, as do changes. Changes get their own jumplist, which is navigable as mentioned above via g,
and g;
(see :help changelist
). Jumps are not treated as motion commands by Vim
When moving up or down across lines, the cursor retains its column as would be expected. If the new line is too short the cursor moves to the end of the new line. If the column is beyond the end of the line, the cursor is displayed at the end of the line. The initial column number is still retained until an action is taken to alter it (such as editing text or explicitly moving column).
If a line's length exceeds the width of the screen, the text is wrapped (under default settings, this behaviour can be configured). To move through lines as displayed on screen, rather than lines within the file, add g in front of the usual command. For example, gj will move the cursor to the position displayed one line below its current position, even if this is in the same line of the file.