Move in vi normal mode without using arrow keys.
Move the cursor one line upward.
Which key should be used?
vi's basic movement keys are h left, j down, k up, and l right in normal mode.
Detailed explanation
hIncorrect. h moves one character left.
jIncorrect. j moves one line down.
kCorrect. k moves one line up.
Correct. k moves one line up, usually preserving the target column when possible.
lIncorrect. l moves one character right.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s\n' 'Vimで2行目にカーソルを置き、ノーマルモードでkを押す'Expected result
カーソルが同じ桁を保ちながら1行上へ移動するKey points
- h moves left
- j moves down
- k moves up
- l moves right
Notes
- Environment: vi/Vimのノーマルモード
- Use a temporary file and harmless edits when testing vi commands.
- Confirm the behavior on the target vi/Vim implementation.
Foundation review
Place the operation
The direction is determined by the key, not by an insertion operation or an editor command line.
Check the side effect
Move from a known line and compare k with j, then h with l.