Edit in vi normal mode.
Open an empty line directly below the current line and begin typing.
Which key should be used?
In normal mode, o opens a new line below the current line and enters insert mode. O opens one above.
Detailed explanation
aIncorrect. a inserts after the cursor within the existing line.
Incorrect. a appends within the current line.
oCorrect. o creates a line below and starts insertion.
Correct. o creates a blank line below and starts insertion there.
iIncorrect. i inserts at the cursor position and does not create a line.
Incorrect. i inserts at the current line position without creating a line.
pIncorrect. p pastes register contents after the cursor or line.
Incorrect. p pastes existing register contents; it does not open an empty line.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp); printf 'first\nthird\n' >"$tmp"; vim -Nu NONE -n -es "$tmp" +'normal ggosecond' +wq; cat "$tmp"; rm -f "$tmp"Expected result
first
second
thirdKey points
- o opens a line below
- O opens a line above
- ESC returns to normal mode
Notes
- Environment: Vim 9.x互換のvi操作 / 一時ファイル
- 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
Line-opening commands differ from commands that continue typing within the current line.
Check the side effect
Start with two lines and verify the new text is between them.